From 08ad62da1c8b7038fe2679175c97a159821f253d Mon Sep 17 00:00:00 2001 From: sleepy ramen Date: Sat, 30 Mar 2024 21:36:49 +0100 Subject: [PATCH] fix: added txid to views; added key and shielded field in tx_transfert view; (#180) closes #174 Small changes on the views to accommodate some users. In brief, we have added txid in all the views and added missing fields in `tx_transfert`. --- src/views.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/views.rs b/src/views.rs index 21d7503..a65f727 100644 --- a/src/views.rs +++ b/src/views.rs @@ -1,6 +1,7 @@ pub fn get_create_tx_become_validator_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_become_validator AS - SELECT + SELECT + hash AS txid, data->>'address' AS address, data->>'consensus_key' AS consensus_key, data->>'eth_cold_key' AS eth_cold_key, @@ -19,6 +20,7 @@ pub fn get_create_tx_become_validator_view_query(network: &str) -> String { pub fn get_create_tx_bond_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_bond AS SELECT + hash AS txid, data->>'validator' AS validator, data->>'amount' AS amount, data->>'source' AS source @@ -28,6 +30,7 @@ pub fn get_create_tx_bond_view_query(network: &str) -> String { pub fn get_create_tx_bridge_pool_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_bridge_pool AS SELECT + hash AS txid, data FROM {network}.transactions WHERE code = '\\x66412b1b01b6659dc196bef86bdb540181d90c2f984a13597f0aa2a4f9c9c907';") } @@ -35,6 +38,7 @@ pub fn get_create_tx_bridge_pool_view_query(network: &str) -> String { pub fn get_create_tx_change_consensus_key_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_change_consensus_key AS SELECT + hash AS txid, data->>'validator' AS validator, data->>'consensus_key' AS consensus_key FROM {network}.transactions WHERE code = '\\x919be890123e9fbe7f85640811f3ca8edfebe94b7314118afbc84ff9c75ec488';") @@ -43,6 +47,7 @@ pub fn get_create_tx_change_consensus_key_view_query(network: &str) -> String { pub fn get_create_tx_change_validator_comission_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_change_validator_comission AS SELECT + hash AS txid, data->>'validator' AS validator, data->>'new_rate' AS new_rate FROM {network}.transactions WHERE code = '\\xf76e025e52c75e34937e76fae43c6ed7544e2268e0bcdafeca0b05f9b7484b36';") @@ -51,6 +56,7 @@ pub fn get_create_tx_change_validator_comission_view_query(network: &str) -> Str pub fn get_create_tx_change_validator_metadata_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_change_validator_metadata AS SELECT + hash AS txid, data->>'validator' AS validator, data->>'email' AS email, data->>'description' AS description, @@ -64,6 +70,7 @@ pub fn get_create_tx_change_validator_metadata_view_query(network: &str) -> Stri pub fn get_create_tx_claim_rewards_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_claim_rewards AS SELECT + hash AS txid, data->>'validator' AS validator, data->>'source' AS source FROM {network}.transactions WHERE code = '\\x4af7ca07f6e6f2ad87ffe2c5fca90224544c45cc263e2e4d05775d782cac1f48';") @@ -72,6 +79,7 @@ pub fn get_create_tx_claim_rewards_view_query(network: &str) -> String { pub fn get_create_tx_deactivate_validator_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_deactivate_validator AS SELECT + hash AS txid, data AS address FROM {network}.transactions WHERE code = '\\x0faaf9b55c150cdf8b2ea6a05c5fae725735b4fee44aa5da79bcd1881cb43f78';") } @@ -79,6 +87,7 @@ pub fn get_create_tx_deactivate_validator_view_query(network: &str) -> String { pub fn get_create_tx_ibc_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_ibc AS SELECT + hash AS txid, data FROM {network}.transactions WHERE code = '\\xf99df82e284dcb96a12b409bc43aa7dc77b346ab0b2d3f0a9a39807e749ce8ee';") } @@ -86,6 +95,7 @@ pub fn get_create_tx_ibc_view_query(network: &str) -> String { pub fn get_create_tx_init_account_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_init_account AS SELECT + hash AS txid, data->>'public_keys' AS public_keys, data->>'vp_code_hash' AS vp_code_hash, data->>'threshold' AS threshold @@ -95,6 +105,7 @@ pub fn get_create_tx_init_account_view_query(network: &str) -> String { pub fn get_create_tx_init_proposal_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_init_proposal AS SELECT + hash AS txid, data->>'id' AS id, data->>'content' AS content, data->>'author' AS author, @@ -108,6 +119,7 @@ pub fn get_create_tx_init_proposal_view_query(network: &str) -> String { pub fn get_create_tx_reactivate_validator_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_reactivate_validator AS SELECT + hash AS txid, data AS address FROM {network}.transactions WHERE code = '\\xc94c4e6d549c921b9a483675f0e3af45eef79d4489bd35061fd285af6189b20d';") } @@ -115,6 +127,7 @@ pub fn get_create_tx_reactivate_validator_view_query(network: &str) -> String { pub fn get_create_tx_redelegate_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_redelegate AS SELECT + hash AS txid, data->>'redel_bond_start' AS redel_bond_start, data->>'src_validator' AS src_validator, data->>'bond_start' AS bond_start, @@ -125,6 +138,7 @@ pub fn get_create_tx_redelegate_view_query(network: &str) -> String { pub fn get_create_tx_resign_steward_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_resign_steward AS SELECT + hash AS txid, data AS address FROM {network}.transactions WHERE code = '\\x7655ed64d1b07900672aee307f679b35af77337c077648adc11914348d1f130f';") } @@ -132,23 +146,28 @@ pub fn get_create_tx_resign_steward_view_query(network: &str) -> String { pub fn get_create_tx_reveal_pk_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_reveal_pk AS SELECT + hash AS txid, data AS public_key FROM {network}.transactions WHERE code = '\\x283fd236d971dd0f7ca1a329b508a4039946f40f1c9792863fe6b0fa05d74832';") } pub fn get_create_tx_transfert_view_query(network: &str) -> String { - format!("CREATE OR REPLACE VIEW {network}.tx_transfert AS + format!("CREATE OR REPLACE VIEW {network}.tx_transfer AS SELECT + hash AS txid, data->>'source' AS source, data->>'target' AS target, data->>'token' AS token, - data->>'amount' AS amount + data->>'amount' AS amount, + data->>'key' AS key, + data->>'shielded' AS shielded FROM {network}.transactions WHERE code = '\\x0960374d23acbac1feb27b3888095859217936c900cef54e559d215cec3206ef';") } pub fn get_create_tx_unbond_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_unbond AS SELECT + hash AS txid, data->>'validator' AS validator, data->>'amount' AS amount, data->>'source' AS source @@ -158,6 +177,7 @@ pub fn get_create_tx_unbond_view_query(network: &str) -> String { pub fn get_create_tx_unjail_validator_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_unjail_validator AS SELECT + hash AS txid, data AS address FROM {network}.transactions WHERE code = '\\x2b1451721dcdd069a19cba1f9b338bb6a45d85d0d56ba7ca952742d3ec5878b3';") } @@ -165,6 +185,7 @@ pub fn get_create_tx_unjail_validator_view_query(network: &str) -> String { pub fn get_create_tx_update_account_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_update_account AS SELECT + hash AS txid, data->>'addr' AS addr, data->>'vp_code_hash' AS vp_code_hash, data->>'public_keys' AS public_keys, @@ -175,6 +196,7 @@ pub fn get_create_tx_update_account_view_query(network: &str) -> String { pub fn get_create_tx_update_steward_commission_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_update_steward_commission AS SELECT + hash AS txid, data->>'steward' AS steward, data->>'commission' AS commission FROM {network}.transactions WHERE code = '\\xed0ccfa4a8c8fa86f9f14c3b53b7f126ce4a86849815dad784b5aa35011a1db6';") @@ -183,6 +205,7 @@ pub fn get_create_tx_update_steward_commission_view_query(network: &str) -> Stri pub fn get_create_tx_vote_proposal_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_vote_proposal AS SELECT + hash AS txid, data->>'id' AS id, data->>'vote' AS vote, data->>'voter' AS voter, @@ -193,6 +216,7 @@ pub fn get_create_tx_vote_proposal_view_query(network: &str) -> String { pub fn get_create_tx_withdraw_view_query(network: &str) -> String { format!("CREATE OR REPLACE VIEW {network}.tx_withdraw AS SELECT + hash AS txid, data->'validator' AS validator, data->'source' AS source FROM {network}.transactions WHERE code = '\\x69560777e2656b2872a49080c51bb5b1a498a7ffd79dae491d36b301a1b012e6';")