Query editor
withprop_votes as (withproposals as (SELECTbytearray_to_uint256(bytearray_substring(l.data,1,32)) as proposal_id, bytearray_substring(l.data,1+32+12,20) as proposer, from_utf8(bytearray_substring(l.data,1+96+32,cast(bytearray_to_uint256(bytearray_substring(l.data,1+96,32)) as bigint))) as proposal, l.tx_hash, l.block_time as proposed_at, aq.created_at, aq.quest_contract_addressFROM optimism.logs lJOIN (SELECTquest_contract_address, created_atFROM query_3307302) aq ON l.contract_address = aq.quest_contract_addressand topic0 = 0x7585f467599d0f008985f231af99293be388626ac16ca59505c2f8f88969cd63-- and bytearray_to_uint256(bytearray_substring(l.data,1,32)) = cast('6005923607797487431104883535377177251458964795650184031931565657690452940520' as uint256))--getting resubmission pids, comments as (SELECT*, row_number() over (partition by proposal_id order by block_time desc) as last_commentFROM (SELECTto as quest_contract_address, bytearray_to_uint256(bytearray_substring(data,1+4,32)) as proposal_id, cast(regexp_extract(from_utf8(bytearray_substring(data,1+4+32+32+32,cast(bytearray_to_uint256(bytearray_substring(data,1+4+32+32,32)) as bigint))), '(\d{71,})') as uint256) as resub_id, block_timeFROM optimism.transactions txWHERE to IN (SELECT quest_contract_address FROM query_3307302)and bytearray_substring(data,1,4) = 0x1805c523and bytearray_to_uint256(bytearray_substring(data,1+4+32+32,32)) < 120 --comment should be less than 120 characters longand tx."from" = 0x4d6E6ef749D2C0E3ee89Fc788A00e28DB71aa6b5-- and to = 0x7a5201647dee74a669d3d4c48d7b963efa6a47e6 --QA)WHERE resub_id is not null), votes as (SELECTcontract_address as quest_contract_address, bytearray_to_uint256(bytearray_substring(data,1,32)) as proposal_id, bytearray_substring(topic1,1+12,20) as voter, least(sum(bytearray_to_uint256(bytearray_substring(data,1+64,32))/1e18),64) as votes --max is 64FROM optimism.logsWHERE contract_address IN (SELECT quest_contract_address FROM query_3307302)and topic0 = 0x2c9deb38f462962eadbd85a9d3a4120503ee091f1582eaaa10aa8c6797651d29and bytearray_to_uint256(bytearray_substring(data,1+32,32)) = 0 --positive direction only-- remove outlier/wrong votesand NOT (bytearray_substring(topic1,1+12,20) = 0x283266045Ab2aB0793a62CADC21D55f685636Ae0 AND contract_address = 0x415b0acc0504059436a2c997f09eeeac7e1f095f)group by 1,2,3)