|
20 | 20 | (topic_0 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' AND topic_3 = '') as is_erc20, |
21 | 21 | (topic_0 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' AND topic_3 != '') as is_erc721, |
22 | 22 | (topic_0 = '0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62') as is_erc1155, |
23 | | - if(is_erc1155, concat('0x', substring(topic_2, 27, 40)), concat('0x', substring(topic_1, 27, 40))) AS sender_address, |
24 | | - if(is_erc1155, concat('0x', substring(topic_3, 27, 40)), concat('0x', substring(topic_2, 27, 40))) AS receiver_address, |
| 23 | + if(is_erc1155, concat('0x', substring(topic_2, 27, 40)), concat('0x', substring(topic_1, 27, 40))) AS sender_address, -- ERC20 & ERC721 both have topic_1 as sender |
| 24 | + if(is_erc1155, concat('0x', substring(topic_3, 27, 40)), concat('0x', substring(topic_2, 27, 40))) AS receiver_address, -- ERC20 & ERC721 both have topic_2 as receiver |
25 | 25 | multiIf(is_erc20, 'erc20', is_erc721, 'erc721', 'erc1155') as token_type, |
26 | 26 | multiIf( |
27 | 27 | is_erc1155, |
|
33 | 33 | multiIf( |
34 | 34 | is_erc20 AND length(data) = 66, |
35 | 35 | reinterpretAsInt256(reverse(unhex(substring(data, 3)))), |
36 | | - is_erc721 OR is_erc1155, |
| 36 | + is_erc721, |
37 | 37 | toInt256(1), |
| 38 | + is_erc1155, |
| 39 | + if(length(data) = 130, reinterpretAsInt256(reverse(unhex(substring(data, 67, 64)))), toInt256(1)), |
38 | 40 | toInt256(0) -- unknown |
39 | | - ) as transfer_amount, |
| 41 | + ) AS transfer_amount, |
40 | 42 | (sign * transfer_amount) as amount |
41 | 43 | FROM logs |
42 | 44 | WHERE |
|
0 commit comments