MLDZMNtrb2
    Updated 2023-02-21
    -- special thanks for Pineherest for tremendous dashboard on Rainbow bridge
    with bridge_native_eth_tx AS (
    SELECT
    tx_hash as tx_bridge,
    substr(data, 259, len(data)) as address_sub,
    -- some debugging to get the right recipient
    len(address_sub) as length,
    case when length = 64 and address_sub LIKE '%17200%' then CONCAT(split_part(address_sub, '17200', 0), '172') -- for near address, length = 64, split part to remove 0 for decode
    when length = 64 and address_sub LIKE '%172172%' then CONCAT(split_part(address_sub, '172172', 0), '172') -- for near address, length = 64, split part to remove 0 for decode
    else address_sub -- unnamed near wallets can be hex decoded directly
    end as address_edited,
    TRY_HEX_DECODE_STRING(address_edited) as recipient
    FROM ethereum.core.fact_event_logs
    WHERE origin_function_signature = '0xa8eb3b51' -- deposit to NEAR
    AND origin_to_address = '0x6bfad42cfc4efc96f529d786d643ff4a8b89fa52'
    AND tx_status = 'SUCCESS'
    ),
    erc20_bridge_tx AS (
    SELECT
    tx_hash as tx_hash_erc20,
    case when event_inputs:accountId LIKE '%aurora:%' then 'AURORA' else 'NEAR' end as bridge_destination,
    event_inputs:accountId::string as recipient,
    event_inputs:sender::string as sender
    FROM ethereum.core.fact_Event_logs
    WHERE origin_function_signature IN ('0x0889bfe7') -- 0x4a00c629 receive
    AND contract_address = '0x23ddd3e3692d1861ed57ede224608875809e127f' -- Rainbow bridge
    AND tx_status = 'SUCCESS'
    AND bridge_destination = 'NEAR'
    ),
    eth_bridge AS (
    SELECT
    block_timestamp,
    tx_hash,
    'NEAR' as bridge_destination,
    origin_from_address as sender,
    recipient,
    Run a query to Download Data