adriaparcerisasList of Flow Contracts
    Updated 2024-12-09
    -- Visualization of valid staged contracts.
    -- Staging Events:
    -- Stage: Counted as staged.
    -- Replace: Counted as staged.
    -- Unstage: Not counted as staged.
    -- Contracts that have not historically had Stage/Replace events: Not counted as staged.

    WITH ContractInit AS (
    SELECT
    event_contract,
    MIN(block_timestamp) AS ContractInitialized_Date,
    MIN(inserted_timestamp) AS InsertedTimestampInit_Date
    FROM flow.core.fact_events
    WHERE event_type = 'ContractInitialized'
    GROUP BY event_contract
    ),
    EventsCount AS (
    SELECT
    event_contract,
    COUNT(DISTINCT tx_id) AS events_emitted
    FROM flow.core.fact_events
    GROUP BY event_contract
    ),
    StagedContracts AS (
    SELECT DISTINCT event_data:contract AS contract
    FROM flow.core.fact_events
    WHERE block_timestamp > '2024-04-01'
    AND event_type ILIKE '%StagingStatusUpdated%'
    AND event_contract = 'A.56100d46aa9b0212.MigrationContractStaging'
    AND event_data:action = 'stage'
    )

    SELECT
    x.event_contract,
    x.contract_name,
    COALESCE(ci.ContractInitialized_Date, '2021-01-01') AS ContractInitialized_Date,
    QueryRunArchived: QueryRun has been archived