@@ -764,23 +764,10 @@ pub fn claim_prize(
764764 return Err ( Error :: InsufficientEscrow ) ;
765765 }
766766
767- // Release token from escrow.
767+ // Release token from escrow — critical path, must succeed .
768768 escrow:: release ( env, & event. token , & recipient, amount) ;
769769 event. remaining_escrow = event. remaining_escrow . saturating_sub ( amount) ;
770770
771- // Cross-contract profile mutations. Each call gets a unique child op_id.
772- let profile = profile_client:: client ( env) ;
773- let reason_win = Symbol :: new ( env, "win" ) ;
774-
775- let bootstrap_op = idempotency:: derive_child ( env, & op_id, tag:: BOOTSTRAP ) ;
776- profile. bootstrap ( & recipient, & bootstrap_op) ;
777-
778- let rep_op = idempotency:: derive_child ( env, & op_id, tag:: BUMP_REP ) ;
779- profile. bump_reputation ( & recipient, & reputation_bump, & reason_win, & rep_op) ;
780-
781- let earnings_op = idempotency:: derive_child ( env, & op_id, tag:: REGISTER_EARNINGS ) ;
782- profile. register_earnings ( & recipient, & event. token , & amount, & earnings_op) ;
783-
784771 // Mark prize claimed (prevents replay for this recipient + position).
785772 storage:: mark_prize_claimed ( env, event_id, & recipient, position) ;
786773
@@ -807,12 +794,26 @@ pub fn claim_prize(
807794
808795 evt:: PrizeClaimed {
809796 event_id,
810- recipient,
797+ recipient : recipient . clone ( ) ,
811798 position,
812799 amount,
813800 }
814801 . publish ( env) ;
815802
803+ // Best-effort profile side effects — payout is already finalised so a
804+ // profile-contract failure must not block the claim.
805+ let profile = profile_client:: client ( env) ;
806+ let reason_win = Symbol :: new ( env, "win" ) ;
807+
808+ let bootstrap_op = idempotency:: derive_child ( env, & op_id, tag:: BOOTSTRAP ) ;
809+ let _ = profile. try_bootstrap ( & recipient, & bootstrap_op) ;
810+
811+ let rep_op = idempotency:: derive_child ( env, & op_id, tag:: BUMP_REP ) ;
812+ let _ = profile. try_bump_reputation ( & recipient, & reputation_bump, & reason_win, & rep_op) ;
813+
814+ let earnings_op = idempotency:: derive_child ( env, & op_id, tag:: REGISTER_EARNINGS ) ;
815+ let _ = profile. try_register_earnings ( & recipient, & event. token , & amount, & earnings_op) ;
816+
816817 idempotency:: mark_seen ( env, & op_id) ;
817818 Ok ( ( ) )
818819}
0 commit comments