From d5db014206036abf29fd31d42149ac9ced7a786f Mon Sep 17 00:00:00 2001 From: thelux134 Date: Tue, 20 Oct 2026 11:13:00 +0100 Subject: [PATCH] Contracts: Use shared market_id_to_u64 for event emission Replace hand-rolled market ID decoding (from_le_bytes with sixteen as_ref calls) in resolve_market and claim_winnings with shared::market_id_to_u64 for consistency with indexers. Closes #1344 --- contracts/market/src/lib.rs | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/contracts/market/src/lib.rs b/contracts/market/src/lib.rs index e27984ff..511bd87b 100644 --- a/contracts/market/src/lib.rs +++ b/contracts/market/src/lib.rs @@ -423,17 +423,7 @@ impl MarketContract { } // Emit market_resolved event with market_id, outcome, and resolution_time - let market_id_u64 = u64::from_le_bytes([ - market.market_id.as_ref()[0], - market.market_id.as_ref()[1], - market.market_id.as_ref()[2], - market.market_id.as_ref()[3], - market.market_id.as_ref()[4], - market.market_id.as_ref()[5], - market.market_id.as_ref()[6], - market.market_id.as_ref()[7], - ]); - events::emit_market_resolved(&env, market_id_u64, outcome, resolution_time); + events::emit_market_resolved(&env, market_id_to_u64(&market.market_id), outcome, resolution_time); } /// Allows a winning bettor to claim their proportional share of the pool. @@ -516,18 +506,6 @@ impl MarketContract { } // Emit winnings_claimed event with market_id, claimant, and amount (payout after fee) - let market_id_u64 = u64::from_le_bytes([ - market.market_id.as_ref()[0], - market.market_id.as_ref()[1], - market.market_id.as_ref()[2], - market.market_id.as_ref()[3], - market.market_id.as_ref()[4], - market.market_id.as_ref()[5], - market.market_id.as_ref()[6], - market.market_id.as_ref()[7], - ]); - - // Create ClaimReceipt for event emission use shared::types::ClaimReceipt; let receipt = ClaimReceipt { bet_id: bet_id.clone(),