@@ -22,7 +22,7 @@ class TransactionBuilder(object):
2222 def __init__ (self , tron ):
2323 self .tron = tron
2424
25- def send_transaction (self , to , amount , account ):
25+ def send_transaction (self , to , amount , account = None ):
2626 """Creates a transaction of transfer.
2727 If the recipient address does not exist, a corresponding account will be created.
2828
@@ -35,6 +35,11 @@ def send_transaction(self, to, amount, account):
3535 Transaction contract data
3636
3737 """
38+
39+ # If the address of the sender is not specified, we prescribe the default
40+ if account is None :
41+ account = self .tron .default_address .hex
42+
3843 if not self .tron .isAddress (to ):
3944 raise InvalidTronError ('Invalid recipient address provided' )
4045
@@ -55,7 +60,7 @@ def send_transaction(self, to, amount, account):
5560
5661 return response
5762
58- def send_token (self , to , amount , token_id , account ):
63+ def send_token (self , to , amount , token_id , account = None ):
5964 """Transfer Token
6065
6166 Args:
@@ -68,6 +73,11 @@ def send_token(self, to, amount, token_id, account):
6873 Token transfer Transaction raw data
6974
7075 """
76+
77+ # If the address of the sender is not specified, we prescribe the default
78+ if account is None :
79+ account = self .tron .default_address .hex
80+
7181 if not self .tron .isAddress (to ):
7282 raise InvalidTronError ('Invalid recipient address provided' )
7383
@@ -98,7 +108,7 @@ def send_token(self, to, amount, token_id, account):
98108 'amount' : amount
99109 })
100110
101- def freeze_balance (self , amount , duration , resource , account ):
111+ def freeze_balance (self , amount , duration , resource , account = None ):
102112 """
103113 Freezes an amount of TRX.
104114 Will give bandwidth OR Energy and TRON Power(voting rights)
@@ -112,6 +122,10 @@ def freeze_balance(self, amount, duration, resource, account):
112122
113123 """
114124
125+ # If the address of the sender is not specified, we prescribe the default
126+ if account is None :
127+ account = self .tron .default_address .hex
128+
115129 if resource not in ('BANDWIDTH' , 'ENERGY' ,):
116130 raise InvalidTronError ('Invalid resource provided: Expected "BANDWIDTH" or "ENERGY"' )
117131
@@ -137,6 +151,19 @@ def freeze_balance(self, amount, duration, resource, account):
137151 return response
138152
139153 def unfreeze_balance (self , resource = 'BANDWIDTH' , account = None ):
154+ """
155+ Unfreeze TRX that has passed the minimum freeze duration.
156+ Unfreezing will remove bandwidth and TRON Power.
157+
158+ Args:
159+ resource (str): type of resource, must be either "ENERGY" or "BANDWIDTH"
160+ account (str): address that is freezing trx account
161+
162+ """
163+
164+ # If the address of the sender is not specified, we prescribe the default
165+ if account is None :
166+ account = self .tron .default_address .hex
140167
141168 if resource not in ('BANDWIDTH' , 'ENERGY' ,):
142169 raise InvalidTronError ('Invalid resource provided: Expected "BANDWIDTH" or "ENERGY"' )
@@ -165,6 +192,7 @@ def purchase_token(self, to: str, token_id: str, amount: int, buyer=None):
165192 buyer (str): is the address of the Token owner
166193
167194 """
195+
168196 if buyer is None :
169197 buyer = self .tron .default_address .hex
170198
@@ -205,14 +233,19 @@ def withdraw_block_rewards(self, address: str = None):
205233 'owner_address' : self .tron .address .to_hex (address )
206234 })
207235
208- def apply_for_sr (self , url , address ):
236+ def apply_for_sr (self , url , address = None ):
209237 """Apply to become a super representative
210238
211239 Args:
212240 url (str): official website address
213241 address (str): address
214242
215243 """
244+
245+ # If the address of the sender is not specified, we prescribe the default
246+ if address is None :
247+ address = self .tron .default_address .hex
248+
216249 if not self .tron .isAddress (address ):
217250 raise TronError ('Invalid address provided' )
218251
@@ -298,7 +331,7 @@ def create_proposal(self, parameters: Any, issuer_address=None):
298331 'parameters' : parameters
299332 })
300333
301- def vote_proposal (self , proposal_id , has_approval , voter_address ):
334+ def vote_proposal (self , proposal_id , has_approval , voter_address = None ):
302335 """Proposal approval
303336
304337 Args:
@@ -307,6 +340,11 @@ def vote_proposal(self, proposal_id, has_approval, voter_address):
307340 voter_address (str): Approve address
308341
309342 """
343+
344+ # If the address of the sender is not specified, we prescribe the default
345+ if voter_address is None :
346+ voter_address = self .tron .default_address .hex
347+
310348 if not self .tron .isAddress (voter_address ):
311349 raise TronError ('Invalid voter_address address provided' )
312350
@@ -322,7 +360,7 @@ def vote_proposal(self, proposal_id, has_approval, voter_address):
322360 'is_add_approval' : bool (has_approval )
323361 })
324362
325- def delete_proposal (self , proposal_id : int , issuer_address : str ):
363+ def delete_proposal (self , proposal_id : int , issuer_address : str = None ):
326364 """Delete proposal
327365
328366 Args:
@@ -333,6 +371,11 @@ def delete_proposal(self, proposal_id: int, issuer_address: str):
333371 Delete the proposal's transaction
334372
335373 """
374+
375+ # If the address of the sender is not specified, we prescribe the default
376+ if issuer_address is None :
377+ issuer_address = self .tron .default_address .hex
378+
336379 if not self .tron .isAddress (issuer_address ):
337380 raise InvalidTronError ('Invalid issuer_address provided' )
338381
@@ -344,7 +387,7 @@ def delete_proposal(self, proposal_id: int, issuer_address: str):
344387 'proposal_id' : int (proposal_id )
345388 })
346389
347- def update_account (self , account_name , account ):
390+ def update_account (self , account_name , account : str = None ):
348391 """Modify account name
349392
350393 Note: Username is allowed to edit only once.
@@ -357,6 +400,11 @@ def update_account(self, account_name, account):
357400 modified Transaction Object
358401
359402 """
403+
404+ # If the address of the sender is not specified, we prescribe the default
405+ if account is None :
406+ account = self .tron .default_address .hex
407+
360408 if not is_string (account_name ):
361409 raise ValueError ('Name must be a string' )
362410
@@ -531,7 +579,7 @@ def create_trx_exchange(self,
531579 token_name : str ,
532580 token_balance : int ,
533581 trx_balance : int ,
534- account ):
582+ account : str = None ):
535583 """Create an exchange between a token and TRX.
536584 Token Name should be a CASE SENSITIVE string.
537585 Note: PLEASE VERIFY THIS ON TRONSCAN.
@@ -543,6 +591,10 @@ def create_trx_exchange(self,
543591 account (str): Owner Address
544592 """
545593
594+ # If the address of the sender is not specified, we prescribe the default
595+ if account is None :
596+ account = self .tron .default_address .hex
597+
546598 if not self .tron .isAddress (account ):
547599 raise TronError ('Invalid address provided' )
548600
@@ -562,7 +614,7 @@ def create_token_exchange(self,
562614 first_token_balance : int ,
563615 second_token_name : str ,
564616 second_token_balance : int ,
565- owner_address = None ):
617+ owner_address : str = None ):
566618 """Create an exchange between a token and another token.
567619 DO NOT USE THIS FOR TRX.
568620 Token Names should be a CASE SENSITIVE string.
@@ -596,8 +648,7 @@ def inject_exchange_tokens(self,
596648 exchange_id : int ,
597649 token_name : str ,
598650 token_amount : int = 0 ,
599- owner_address = None
600- ):
651+ owner_address : str = None ):
601652 """Adds tokens into a bancor style exchange.
602653 Will add both tokens at market rate.
603654
@@ -607,8 +658,6 @@ def inject_exchange_tokens(self,
607658 token_amount (int): amount of token
608659 owner_address (str): token owner address in hex
609660
610- Returns:
611-
612661 """
613662 if owner_address is None :
614663 owner_address = self .tron .default_address .hex
@@ -768,7 +817,7 @@ def withdraw_exchange_tokens(self,
768817 exchange_id : int ,
769818 token_name : str ,
770819 token_amount : int = 0 ,
771- owner_address = None ):
820+ owner_address : str = None ):
772821 """Withdraws tokens from a bancor style exchange.
773822 Will withdraw at market rate both tokens.
774823
@@ -803,7 +852,7 @@ def trade_exchange_tokens(self,
803852 token_name : str ,
804853 token_amount_sold : int = 0 ,
805854 token_amount_expected : int = 0 ,
806- owner_address = None ):
855+ owner_address : str = None ):
807856 """Trade tokens on a bancor style exchange.
808857 Expected value is a validation and used to cap the total amt of token 2 spent.
809858
@@ -842,7 +891,7 @@ def trade_exchange_tokens(self,
842891 def update_setting (self ,
843892 contract_address ,
844893 user_fee_percentage ,
845- owner_address = None ):
894+ owner_address : str = None ):
846895 """Update userFeePercentage.
847896
848897 Args:
@@ -876,7 +925,7 @@ def update_setting(self,
876925 def update_energy_limit (self ,
877926 contract_address ,
878927 origin_energy_limit ,
879- owner_address = None ):
928+ owner_address : str = None ):
880929 """Update energy limit.
881930
882931 Args:
0 commit comments