Query editor
-- need a from_base58 decoder function for SQL (postgres), i don't think there's a way to go around that in solanaWITH vote_tx AS (SELECTfromBase58(instruction.a) AS vote_data,instruction.c[1] AS vote_account,instruction.c[2] AS validator_identity,vt.block_slot AS vote_inclusion_slotFROM solana.vote_transactions AS vtCROSS JOIN UNNEST (instructions) AS instruction (a, b, c, d)WHERE block_time >= TIMESTAMP '2024-03-03 16:29:12 UTC' --epoch 583 startAND block_time <= TIMESTAMP '2024-03-05 17:35:54 UTC' --epoch 583 endAND signer = 'LA1NEzryoih6CQW3gwQqJQffK2mKgnXcjSQZSRpM3wc' -- LaineAND success = trueAND bytearray_to_bigint(bytearray_reverse(bytearray_substring(fromBase58(instruction.a), 1, 1))) IN (12, 13)AND instruction.c[1] = 'GE6atKoWiQ2pt3zL7N13pjNHjdLVys8LinG8qeJLcAiL' -- Laine),votes_metadata AS (SELECTbytearray_substring(vote_data, 1, 1) AS discriminator, --function signature of a program; in this case the function signature for voting of the Vote Programbytearray_to_bigint(bytearray_reverse(bytearray_substring(vote_data, 5, 4))) AS root_slot_with_32_conf,bytearray_to_bigint(bytearray_reverse(bytearray_substring(vote_data, 13, 1))) AS votes_in_tower,bytearray_to_bigint(bytearray_reverse(bytearray_substring(vote_data, 13, 1))) + 1 AS slots_in_vote_tx, -- 31 in tower plus the rootvalidator_identity,vote_account,vote_inclusion_slot,vote_dataFROM vote_tx),vote_offsets AS (SELECTvalidator_identity,vote_account,vote_inclusion_slot,root_slot_with_32_conf,CASEWHEN 1 <= votes_in_tower THEN bytearray_to_bigint(bytearray_substring(vote_data, 14, 1))ELSE 0END AS offset_1,CASEWHEN 2 <= votes_in_tower THEN bytearray_to_bigint(bytearray_substring(vote_data, 16, 1))ELSE 0END AS offset_2,CASEWHEN 3 <= votes_in_tower THEN bytearray_to_bigint(bytearray_substring(vote_data, 18, 1))ELSE 0END AS offset_3,CASEWHEN 4 <= votes_in_tower THEN bytearray_to_bigint(bytearray_substring(vote_data, 20, 1))ELSE 0END AS offset_4,CASEWHEN 5 <= votes_in_tower THEN bytearray_to_bigint(bytearray_substring(vote_data, 22, 1))ELSE 0