Skip to content

[Backend] — Scheduled auto-finalization of ended events #960

@Olowodarey

Description

@Olowodarey

Background

Contract Issue 6 makes finalize_event permissionless — anyone can call
it once event.has_ended() is true and all of the event's matches have a
result. The backend already holds a server-controlled keypair
(SERVER_SECRET_KEY, validated in `src/config/env.validation.

Goal

Add a scheduled job that finds events past their end_time with all
matches resolved and not yet finalized, and calls finalize_event for each
using the server keypair.

Tasks

  1. New SorobanService method finalizeEvent(onChainEventId: number): 151-220), invoking the contract's finalize_event(event_id)` function
  2. New service src/matches/creator-event-finalizer.service.ts:
    1 — add is_finalized to that index list too if not already) so this
  3. Register CreatorEventFinalizerService in MatchesModule (or a new
  4. Defensive bound: cap the number of finalize_event calls per cron

Acceptance Criteria

  • An event with end_time in the past, is_finalized = false, and all
  • An event with end_time in the past but at least one unresolved match
  • An already-finalized event (is_finalized = true) is excluded from
  • A finalize_event RPC failure for one event is logged and does not
  • No more than 20 finalize_event calls happen per cron tick

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions