@@ -5,9 +5,9 @@ use crate::state::Event;
55use crate :: { error:: BettingError , Config , EventStatus , Outcome } ;
66
77// Close one Outcome account of a finished event and return its rent to the
8- // admin, who paid it. Bet accounts derive their address from the outcome's,
9- // so every bet of the event must already be closed , and the Outcome accounts
10- // must all close before `close_event` can close the event.
8+ // admin, who paid it. The event's accounts close in the reverse of the order
9+ // they were created: every Bet of the event before any Outcome , and every
10+ // Outcome before `close_event` can close the event.
1111#[ derive( Accounts ) ]
1212pub struct CloseOutcomeAccountConstraints {
1313 #[ account( mut , address = config. admin @ BettingError :: Unauthorized ) ]
@@ -42,9 +42,13 @@ pub fn handle_close_outcome(context: &mut Context<CloseOutcomeAccountConstraints
4242 ) ,
4343 BettingError :: EventNotFinished
4444 ) ;
45- // A Bet account derives its address from its outcome's, so an outcome
46- // closed under an open bet would leave that bet's claim or refund with
47- // no outcome to check against.
45+ // No claim, refund or losing-bet close reads the Outcome: each re-derives
46+ // the Bet address from the outcome pubkey the Bet stores, which stays
47+ // valid as bytes after the Outcome closes. This check is an ordering
48+ // rule, not something those handlers need: an Outcome stays open for as
49+ // long as any Bet of the event names it by address, so no live position
50+ // ever points at an address the program has emptied, and the event's
51+ // `open_bets` counter is the gate.
4852 require ! (
4953 context. accounts. event. open_bets == 0 ,
5054 BettingError :: BetsStillOpen
0 commit comments