Skip to content

Commit

Permalink
Correctly state the statust, declaration in the database
Browse files Browse the repository at this point in the history
  • Loading branch information
af-afk committed Jan 30, 2025
1 parent 620ea98 commit 16021a9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/types/events/9lives.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ type (
TradingAddr Address `json:"trading_addr"`
}

EventDeclared struct {
Event

TradingAddr Address `json:"trading_addr"`
WinningOutcome Bytes `json:"winning_outcome"`
FeeRecipient Address `json:"fee_recipient"`
}

EventLockedUp struct {
Event

Expand Down
1 change: 1 addition & 0 deletions src/IEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ interface IEvents {

event InfraMarketUpdated(address indexed old, address indexed new_);

/// @notice Declare was called on a market in the infra market.
event Declared(
address indexed trading,
bytes8 indexed winningOutcome,
Expand Down
2 changes: 1 addition & 1 deletion src/contract_infra_market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl StorageInfraMarket {
}
// If the winner was called, but no-one whinged, and we're outside two days,
// then we're callable.
_ if time_since_called > TWO_DAYS && !has_whinged => (InfraMarketState::Closable, 0),
_ if time_since_called > TWO_DAYS && !has_whinged && !is_winner_set => (InfraMarketState::Closable, 0),
// If the winner was declared, two days has passed, and we're in a state where
// no-one whinged, then we need to assume we were closed.
_ if time_since_called > TWO_DAYS && !has_whinged => (InfraMarketState::Closed, 0),
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e-infra-market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ proptest! {
Error::NotAfterWhinging
);
});
// Add two days.
ts_add_time(block_timestamp() + 24 * 60 * 60 * 2);
c.close(trading_addr, msg_sender()).unwrap();
assert_eq!(
{ let c: u8 = InfraMarketState::Closed.into(); c },
c.status(trading_addr).unwrap().0,
);
}
}
}
Expand Down

0 comments on commit 16021a9

Please sign in to comment.