diff --git a/.sqlx/query-391efd59ae4d18800d3ed5e1850083a8b5aa335fbb27bd607e546e44e9544e92.json b/.sqlx/query-391efd59ae4d18800d3ed5e1850083a8b5aa335fbb27bd607e546e44e9544e92.json new file mode 100644 index 0000000..a884970 --- /dev/null +++ b/.sqlx/query-391efd59ae4d18800d3ed5e1850083a8b5aa335fbb27bd607e546e44e9544e92.json @@ -0,0 +1,213 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH\n user_command_info AS (\n SELECT DISTINCT\n ON (uca.block_id, uca.id, uca.sequence_no) uca.id,\n uca.command_type AS \"command_type: UserCommandType\",\n uca.fee_payer_id,\n uca.source_id,\n uca.receiver_id,\n uca.nonce,\n uca.amount,\n uca.fee,\n uca.valid_until,\n uca.memo,\n uca.hash,\n uca.block_id,\n uca.sequence_no,\n uca.status AS \"status: TransactionStatus\",\n uca.failure_reason,\n b.state_hash,\n b.chain_status AS \"chain_status: ChainStatus\",\n b.height\n FROM\n user_commands_aggregated AS uca\n INNER JOIN public_keys AS pk ON uca.fee_payer_id=pk.id\n OR (\n uca.status='applied'\n AND (\n uca.source_id=pk.id\n OR uca.receiver_id=pk.id\n )\n )\n INNER JOIN blocks AS b ON uca.block_id=b.id\n WHERE\n (\n b.chain_status='canonical'\n OR b.chain_status='pending'\n )\n AND (\n $1>=b.height\n OR $1 IS NULL\n )\n AND (\n $2=uca.hash\n OR $2 IS NULL\n )\n AND (\n $3=pk.value\n AND $4=''\n OR (\n $3 IS NULL\n AND $4 IS NULL\n )\n )\n AND (\n $5=uca.status\n OR $5 IS NULL\n )\n AND (\n $6=uca.status\n OR $6 IS NULL\n )\n AND (\n $7=pk.value\n OR $7 IS NULL\n )\n ),\n id_count AS (\n SELECT\n count(*) AS total_count\n FROM\n user_command_info\n )\nSELECT\n u.*,\n id_count.total_count,\n pk_payer.value AS fee_payer,\n pk_source.value AS source,\n pk_receiver.value AS receiver,\n ac.creation_fee AS \"creation_fee?\"\nFROM\n id_count,\n (\n SELECT\n *\n FROM\n user_command_info\n ORDER BY\n block_id,\n id,\n sequence_no\n LIMIT\n $8\n OFFSET\n $9\n ) AS u\n INNER JOIN public_keys AS pk_payer ON u.fee_payer_id=pk_payer.id\n INNER JOIN public_keys AS pk_source ON u.source_id=pk_source.id\n INNER JOIN public_keys AS pk_receiver ON u.receiver_id=pk_receiver.id\n /* Account creation fees are attributed to the first successful command in the\n block that mentions the account with the following LEFT JOINs */\n LEFT JOIN account_identifiers AS ai_receiver ON u.receiver_id=ai_receiver.public_key_id\n LEFT JOIN accounts_created AS ac ON u.block_id=ac.block_id\n AND ai_receiver.id=ac.account_identifier_id\n AND u.\"status: TransactionStatus\"='applied'\n AND u.sequence_no=(\n SELECT\n least(\n (\n SELECT\n min(bic2.sequence_no)\n FROM\n blocks_internal_commands AS bic2\n INNER JOIN internal_commands AS ic2 ON bic2.internal_command_id=ic2.id\n WHERE\n u.receiver_id=ic2.receiver_id\n AND bic2.block_id=u.block_id\n AND bic2.status='applied'\n ),\n (\n SELECT\n min(buc2.sequence_no)\n FROM\n blocks_user_commands AS buc2\n INNER JOIN user_commands AS uc2 ON buc2.user_command_id=uc2.id\n WHERE\n u.receiver_id=uc2.receiver_id\n AND buc2.block_id=u.block_id\n AND buc2.status='applied'\n )\n )\n )\nORDER BY\n u.block_id,\n u.id,\n u.sequence_no\n", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "command_type: UserCommandType", + "type_info": { + "Custom": { + "name": "user_command_type", + "kind": { + "Enum": [ + "payment", + "delegation" + ] + } + } + } + }, + { + "ordinal": 2, + "name": "fee_payer_id", + "type_info": "Int4" + }, + { + "ordinal": 3, + "name": "source_id", + "type_info": "Int4" + }, + { + "ordinal": 4, + "name": "receiver_id", + "type_info": "Int4" + }, + { + "ordinal": 5, + "name": "nonce", + "type_info": "Int8" + }, + { + "ordinal": 6, + "name": "amount", + "type_info": "Text" + }, + { + "ordinal": 7, + "name": "fee", + "type_info": "Text" + }, + { + "ordinal": 8, + "name": "valid_until", + "type_info": "Int8" + }, + { + "ordinal": 9, + "name": "memo", + "type_info": "Text" + }, + { + "ordinal": 10, + "name": "hash", + "type_info": "Text" + }, + { + "ordinal": 11, + "name": "block_id", + "type_info": "Int4" + }, + { + "ordinal": 12, + "name": "sequence_no", + "type_info": "Int4" + }, + { + "ordinal": 13, + "name": "status: TransactionStatus", + "type_info": { + "Custom": { + "name": "transaction_status", + "kind": { + "Enum": [ + "applied", + "failed" + ] + } + } + } + }, + { + "ordinal": 14, + "name": "failure_reason", + "type_info": "Text" + }, + { + "ordinal": 15, + "name": "state_hash", + "type_info": "Text" + }, + { + "ordinal": 16, + "name": "chain_status: ChainStatus", + "type_info": { + "Custom": { + "name": "chain_status_type", + "kind": { + "Enum": [ + "canonical", + "orphaned", + "pending" + ] + } + } + } + }, + { + "ordinal": 17, + "name": "height", + "type_info": "Int8" + }, + { + "ordinal": 18, + "name": "total_count", + "type_info": "Int8" + }, + { + "ordinal": 19, + "name": "fee_payer", + "type_info": "Text" + }, + { + "ordinal": 20, + "name": "source", + "type_info": "Text" + }, + { + "ordinal": 21, + "name": "receiver", + "type_info": "Text" + }, + { + "ordinal": 22, + "name": "creation_fee?", + "type_info": "Text" + } + ], + "parameters": { + "Left": [ + "Int8", + "Text", + "Text", + "Text", + { + "Custom": { + "name": "transaction_status", + "kind": { + "Enum": [ + "applied", + "failed" + ] + } + } + }, + { + "Custom": { + "name": "transaction_status", + "kind": { + "Enum": [ + "applied", + "failed" + ] + } + } + }, + "Text", + "Int8", + "Int8" + ] + }, + "nullable": [ + true, + false, + false, + false, + false, + false, + true, + false, + true, + false, + false, + false, + false, + false, + true, + false, + false, + false, + null, + false, + false, + false, + false + ] + }, + "hash": "391efd59ae4d18800d3ed5e1850083a8b5aa335fbb27bd607e546e44e9544e92" +}