@@ -154,19 +154,14 @@ def rejection_reason(self) -> Optional[str]:
154154 return None
155155
156156 request_memo = next (
157- (
158- m
159- for m in self .memos
160- if m .next_phase == ACPJobPhase .NEGOTIATION
161- ),
157+ (m for m in self .memos if m .next_phase == ACPJobPhase .NEGOTIATION ),
162158 None ,
163159 )
164160 if request_memo :
165161 return request_memo .signed_reason
166162
167163 fallback_memo = next (
168- (m for m in self .memos if m .next_phase == ACPJobPhase .REJECTED ),
169- None
164+ (m for m in self .memos if m .next_phase == ACPJobPhase .REJECTED ), None
170165 )
171166 return fallback_memo .content if fallback_memo else None
172167
@@ -293,9 +288,12 @@ def pay_and_accept_requirement(self, reason: Optional[str] = "") -> str | None:
293288 )
294289 )
295290
296- x402PaymentDetails = self .acp_contract_client .get_x402_payment_details (self .id )
297- if x402PaymentDetails .is_x402 :
298- self .perform_x402_payment (self .price )
291+ if self .price > 0 :
292+ x402PaymentDetails = self .acp_contract_client .get_x402_payment_details (
293+ self .id
294+ )
295+ if x402PaymentDetails .is_x402 :
296+ self .perform_x402_payment (self .price )
299297
300298 response = self .acp_contract_client .handle_operation (operations )
301299 return get_txn_hash_from_response (response )
@@ -325,7 +323,7 @@ def reject(self, reason: Optional[str] = None) -> str | None:
325323 content = memo_content ,
326324 memo_type = MemoType .MESSAGE ,
327325 is_secured = True ,
328- next_phase = ACPJobPhase .REJECTED
326+ next_phase = ACPJobPhase .REJECTED ,
329327 )
330328 )
331329
@@ -347,8 +345,7 @@ def reject_payable(
347345
348346 operations .append (
349347 self .acp_contract_client .approve_allowance (
350- amount .amount ,
351- amount .fare .contract_address
348+ amount .amount , amount .fare .contract_address
352349 )
353350 )
354351
@@ -520,8 +517,7 @@ def create_payable_notification(
520517
521518 operations .append (
522519 self .acp_contract_client .approve_allowance (
523- amount .amount ,
524- amount .fare .contract_address
520+ amount .amount , amount .fare .contract_address
525521 )
526522 )
527523
@@ -543,7 +539,7 @@ def create_payable_notification(
543539 next_phase = ACPJobPhase .COMPLETED ,
544540 memo_type = MemoType .PAYABLE_NOTIFICATION ,
545541 expired_at = expired_at ,
546- token = amount .fare .contract_address
542+ token = amount .fare .contract_address ,
547543 )
548544 )
549545
@@ -590,7 +586,10 @@ def perform_x402_payment(self, budget: float):
590586 self .acp_contract_client .update_job_x402_nonce (self .id , str (nonce ))
591587
592588 x402_response = self .acp_contract_client .perform_x402_request (
593- payment_url , self .acp_contract_client .get_acp_version (), str (budget ), encoded_payment
589+ payment_url ,
590+ self .acp_contract_client .get_acp_version (),
591+ str (budget ),
592+ encoded_payment ,
594593 )
595594 if x402_response .get ("isPaymentRequired" ):
596595 # If payment is required, submit transfer with authorization and handle the operation
0 commit comments