Query editor
withmints as (withmint_collection_v1 as (SELECTaccount_merkleTree, json_value(metadataArgs, 'strict $.MetadataArgs.name') as token_name, json_value(metadataArgs, 'strict $.MetadataArgs.symbol') as token_symbol, replace(replace(json_value(metadataArgs, 'strict $.MetadataArgs.collection.Collection.key'), 'PublicKey(', ''), ')','') as collection_mint, call_block_slot, call_block_time, call_outer_instruction_index, call_inner_instruction_index, account_leafOwnerFROM bubblegum_solana.bubblegum_call_mintToCollectionV1WHERE 1=1), mint_v1 as (SELECTaccount_merkleTree, json_value(message, 'strict $.MetadataArgs.name') as token_name, json_value(message, 'strict $.MetadataArgs.symbol') as token_symbol, replace(replace(json_value(message, 'strict $.MetadataArgs.collection.Collection.key'), 'PublicKey(', ''), ')','') as collection_mint, call_block_slot, call_block_time, call_outer_instruction_index, call_inner_instruction_index, account_leafOwnerFROM bubblegum_solana.bubblegum_call_mintV1)SELECT*, row_number() over (partition by account_merkleTreeorder by call_block_slot asc, call_outer_instruction_index asc, COALESCE(call_inner_instruction_index,0) asc)as leaf_idFROM (SELECT * FROM mint_collection_v1UNION ALLSELECT * FROM mint_v1)WHERE collection_mint = '{{collection mint}}'), transfers as (SELECTaccount_newLeafOwner, tr.index as leaf_id, tr.account_merkleTree, tr.call_block_time, tr.call_outer_instruction_index, COALESCE(tr.call_inner_instruction_index,0) as call_inner_instruction_index, row_number() over (partition by tr.account_merkleTree, tr.indexorder by tr.call_block_slot desc, tr.call_outer_instruction_index desc, COALESCE(tr.call_inner_instruction_index,0) desc)as last_transferFROM bubblegum_solana.bubblegum_call_transfer trJOIN tokens_solana.nft nftON nft.account_merkle_tree = tr.account_merkleTreeAND nft.leaf_id = tr.indexAND nft.collection_mint = '{{collection mint}}'