bergDaily Redelegation transactions before Proposal NO. 82
    Updated 2022-12-12
    with tbl1 as (
    select block_timestamp,
    tx_id,
    a.attribute_value as voter,
    try_parse_json (c.attribute_value) as metadata,
    metadata:option as vote_option,
    case vote_option
    when '1' then 'Yes'
    when '2' then 'Abstain'
    when '3' then 'No'
    when '4' then 'No With Veto'
    end as vote_value
    from cosmos.core.fact_msg_attributes a
    join cosmos.core.fact_msg_attributes b
    using(tx_id)
    join cosmos.core.fact_msg_attributes c
    using(tx_id)
    where a.attribute_key = 'spender'
    and b.attribute_key = 'proposal_id'
    and b.attribute_value = '82'
    and c.attribute_key = 'option'
    and a.tx_succeeded = 1
    ),


    tbl2 as (
    select tx_id,
    split(a.attribute_value,'uatom')[0]::numeric/1e6 as redelegate_amount,
    a.block_timestamp as redelegate_date,
    b.attribute_value as redelegator
    from cosmos.core.fact_msg_attributes a
    join cosmos.core.fact_msg_attributes b
    using (tx_id)
    where a.msg_type = 'redelegate'
    and a.attribute_key = 'amount'
    and a.attribute_value ilike '%uatom%'