Skip to content

Commit

Permalink
fix: use u64 (instead of i64)
Browse files Browse the repository at this point in the history
Fields include: limit, blocks_limit, snarks_limit, trans_limit, epoch, current_epoch, slot_in_epoch, selected_epoch, height, block_height, nonce, and slot

Fixes Granola-Team#600

Related:
- graphql-rust/graphql-client#266
- graphql-rust/graphql-parser#53

a
  • Loading branch information
jhult committed Jun 26, 2024
1 parent 352e1e6 commit 825c50a
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 61 deletions.
22 changes: 13 additions & 9 deletions src/account_activity/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,30 @@ pub fn get_base_page_path(location: Location) -> String {
#[allow(clippy::too_many_arguments)]
pub async fn load_data(
public_key: Option<String>,
blocks_limit: Option<i64>,
snarks_limit: Option<i64>,
trans_limit: Option<i64>,
block_height: Option<i64>,
blocks_limit: Option<u64>,
snarks_limit: Option<u64>,
trans_limit: Option<u64>,
block_height: Option<u64>,
txn_hash: Option<String>,
state_hash: Option<String>,
prover: Option<String>,
nonce: Option<i64>,
nonce: Option<u64>,
counterparty: Option<String>,
slot: Option<i64>,
slot: Option<u64>,
block_producer: Option<String>,
canonical: Option<bool>,
) -> Result<account_activity_query::ResponseData, MyError> {
let block_height = Some(block_height.unwrap_or_default() as i64);
let nonce = Some(nonce.unwrap_or_default() as i64);
let slot = Some(slot.unwrap_or_default() as i64);

let variables = account_activity_query::Variables {
blocks_sort_by: account_activity_query::BlockSortByInput::BLOCKHEIGHT_DESC,
snarks_sort_by: account_activity_query::SnarkSortByInput::BLOCKHEIGHT_DESC,
trans_sort_by: account_activity_query::TransactionSortByInput::BLOCKHEIGHT_DESC,
blocks_limit: Some(blocks_limit.unwrap_or_default()),
snarks_limit: Some(snarks_limit.unwrap_or_default()),
trans_limit: Some(trans_limit.unwrap_or_default()),
blocks_limit: Some(blocks_limit.unwrap_or_default() as i64),
snarks_limit: Some(snarks_limit.unwrap_or_default() as i64),
trans_limit: Some(trans_limit.unwrap_or_default() as i64),
account_query: account_activity_query::AccountQueryInput {
public_key: public_key.clone(),
username: None,
Expand Down
12 changes: 6 additions & 6 deletions src/account_activity/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ pub struct AccountActivityQueryDirectionalTransactions {
pub hash: Option<String>,
pub amount: Option<f64>,
pub date_time: Option<DateTime<Utc>>,
pub height: Option<i64>,
pub height: Option<u64>,
pub kind: Option<String>,
pub nonce: Option<i64>,
pub nonce: Option<u64>,
pub failure_reason: Option<String>,
pub memo: Option<String>,
pub canonical: Option<bool>,
Expand All @@ -76,9 +76,9 @@ impl From<AccountActivityQueryIncomingTransactions>
} else {
None
},
height: i.block_height,
height: Some(i.block_height.unwrap_or_default() as u64),
kind: i.kind,
nonce: i.nonce,
nonce: Some(i.nonce.unwrap_or_default() as u64),
failure_reason: i.failure_reason,
memo: i.memo,
canonical: i.canonical,
Expand Down Expand Up @@ -107,9 +107,9 @@ impl From<AccountActivityQueryOutgoingTransactions>
} else {
None
},
height: i.block_height,
height: Some(i.block_height.unwrap_or_default() as u64),
kind: i.kind,
nonce: i.nonce,
nonce: Some(i.nonce.unwrap_or_default() as u64),
failure_reason: i.failure_reason,
memo: i.memo,
canonical: i.canonical,
Expand Down
6 changes: 3 additions & 3 deletions src/account_activity/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub fn AccountSpotlightPage() -> impl IntoView {
let memo_params_map = use_params_map();
let query_params_map = use_query_map();
let (canonical_sig, _) = create_query_signal::<bool>("canonical");
let (block_height_sig, _) = create_query_signal::<i64>("q-height");
let (nonce_sig, _) = create_query_signal::<i64>("q-nonce");
let (slot_sig, _) = create_query_signal::<i64>("q-slot");
let (block_height_sig, _) = create_query_signal::<u64>("q-height");
let (nonce_sig, _) = create_query_signal::<u64>("q-nonce");
let (slot_sig, _) = create_query_signal::<u64>("q-slot");
let (transactions, set_transactions) = create_signal(None);
let (snarks, set_snarks) = create_signal(None);
let (blocks, set_blocks) = create_signal(None);
Expand Down
4 changes: 2 additions & 2 deletions src/accounts/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::common::{constants::GRAPHQL_ENDPOINT, models::*};
use graphql_client::reqwest::post_graphql;

pub async fn load_data(
limit: i64,
limit: u64,
public_key: Option<String>,
username: Option<String>,
balance: Option<i64>,
Expand All @@ -19,7 +19,7 @@ pub async fn load_data(
};

let variables = accounts_query::Variables {
limit: Some(limit),
limit: Some(limit as i64),
query,
sort_by: accounts_query::AccountSortByInput::BALANCE_DESC,
};
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ pub fn BlocksSection() -> impl IntoView {
use_local_storage::<BlockchainSummary, JsonCodec>(BLOCKCHAIN_SUMMARY_STORAGE_KEY);
let query_params_map = use_query_map();
let (data_sig, set_data_sig) = create_signal(None);
let (block_height_sig, _) = create_query_signal::<i64>("q-height");
let (slot_sig, _) = create_query_signal::<i64>("q-slot");
let (block_height_sig, _) = create_query_signal::<u64>("q-height");
let (slot_sig, _) = create_query_signal::<u64>("q-slot");
let (canonical_sig, _) = create_query_signal::<bool>("canonical");
let UseIntervalReturn { counter, .. } = use_interval(LIVE_RELOAD_INTERVAL);

Expand Down
12 changes: 6 additions & 6 deletions src/blocks/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,27 @@ pub fn get_coinbase_receiver(block: &BlocksQueryBlocks) -> String {
}

pub async fn load_data(
limit: i64,
limit: u64,
block_creator_account: Option<String>,
state_hash: Option<String>,
block_height: Option<i64>,
slot: Option<i64>,
block_height: Option<u64>,
slot: Option<u64>,
canonical: Option<bool>,
) -> Result<blocks_query::ResponseData, MyError> {
let variables = blocks_query::Variables {
sort_by: blocks_query::BlockSortByInput::BLOCKHEIGHT_DESC,
limit: Some(limit),
limit: Some(limit as i64),
query: blocks_query::BlockQueryInput {
canonical,
state_hash,
block_height_lte: block_height,
block_height_lte: Some(block_height.unwrap_or_default() as i64),
creator_account: Some(blocks_query::BlockCreatorAccountQueryInput {
public_key: block_creator_account,
..Default::default()
}),
protocol_state: Some(blocks_query::BlockProtocolStateQueryInput {
consensus_state: Some(blocks_query::BlockProtocolStateConsensusStateQueryInput {
slot_since_genesis_lte: slot,
slot_since_genesis_lte: Some(slot.unwrap_or_default() as i64),
..Default::default()
}),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion src/common/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub const EPOCH_SLOTS: u16 = 7140;
pub const DEFAULT_USER_INPUT_DEBOUNCE_INTERNVAL: f64 = 500.0;
pub const GLOBAL_SEARCH_PLACEHOLDER_TEXT: &str = "Paste -> Enter -> Explore!";
pub const LIVE_RELOAD_INTERVAL: u64 = 60000;
pub const TABLE_ROW_LIMIT: i64 = 25;
pub const TABLE_ROW_LIMIT: u64 = 25;
pub const COMMIT_HASH: &str = env!("COMMIT_HASH");
pub const LINK_HOVER_STATE: &str = "hover:text-granola-orange hover:underline hover:decoration-2 ";
pub const TABLE_COL_NUMERIC_WIDTH: &str = "150px";
Expand Down
2 changes: 1 addition & 1 deletion src/common/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use serde::*;
#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
struct EpochData {
pub epoch: Option<i64>,
pub epoch: Option<u64>,
pub ledger_hash: Option<String>,
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where
view! {
<TableRows data=vec![
vec![LoadingPlaceholder; table_cols_length];
TABLE_ROW_LIMIT.try_into().unwrap_or_default()
TABLE_ROW_LIMIT as usize
]/>
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/internal_commands/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn InternalCommandsTab() -> impl IntoView {
use_local_storage::<BlockchainSummary, JsonCodec>(BLOCKCHAIN_SUMMARY_STORAGE_KEY);
let (data_sig, set_data) = create_signal(None);
let (recipient, _) = create_query_signal::<String>("q-recipient");
let (height_sig, _) = create_query_signal::<i64>("q-height");
let (height_sig, _) = create_query_signal::<u64>("q-height");
let (state_hash_sig, _) = create_query_signal::<String>("q-state-hash");
let (canonical_sig, _) = create_query_signal::<bool>("canonical");
let resource = create_resource(
Expand Down
6 changes: 3 additions & 3 deletions src/internal_commands/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use graphql_client::reqwest::post_graphql;

pub async fn load_data(
recipient: Option<String>,
block_height: Option<i64>,
block_height: Option<u64>,
state_hash: Option<String>,
canonical: Option<bool>,
) -> Result<internal_commands_query::ResponseData, MyError> {
let variables = internal_commands_query::Variables {
sort_by: internal_commands_query::FeetransferSortByInput::BLOCKHEIGHT_DESC,
limit: Some(TABLE_ROW_LIMIT),
limit: Some(TABLE_ROW_LIMIT as i64),
query: internal_commands_query::FeetransferQueryInput {
block_height_lte: block_height,
block_height_lte: Some(block_height.unwrap_or_default() as i64),
block_state_hash: state_hash.map(|sh| BlockQueryInput {
state_hash: Some(sh),
..Default::default()
Expand Down
6 changes: 3 additions & 3 deletions src/snarks/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ use graphql_client::reqwest::post_graphql;
pub async fn load_data(
prover: Option<String>,
block_state_hash: Option<String>,
block_height: Option<i64>,
block_height: Option<u64>,
canonical: Option<bool>,
) -> Result<snarks_query::ResponseData, MyError> {
let variables = snarks_query::Variables {
sort_by: snarks_query::SnarkSortByInput::BLOCKHEIGHT_DESC,
limit: Some(TABLE_ROW_LIMIT),
limit: Some(TABLE_ROW_LIMIT as i64),
query: snarks_query::SnarkQueryInput {
block_height_lte: block_height,
block_height_lte: Some(block_height.unwrap_or_default() as i64),
prover,
canonical: if canonical.is_none() {
Some(true)
Expand Down
2 changes: 1 addition & 1 deletion src/snarks/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn SnarksPageContents() -> impl IntoView {
let (data_sig, set_data) = create_signal(None);
let query_params_map = use_query_map();
let (canonical_qp, _) = create_query_signal::<bool>("canonical");
let (block_height_sig, _) = create_query_signal::<i64>("q-height");
let (block_height_sig, _) = create_query_signal::<u64>("q-height");
let UseIntervalReturn { counter, .. } = use_interval(LIVE_RELOAD_INTERVAL);

let resource = create_resource(
Expand Down
10 changes: 5 additions & 5 deletions src/stakes/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use leptos_router::*;

#[component]
pub fn StakesPageContents(
#[prop(into)] current_epoch: i64,
#[prop(into)] slot_in_epoch: i64,
selected_epoch: Option<i64>,
#[prop(into)] current_epoch: u64,
#[prop(into)] slot_in_epoch: u64,
selected_epoch: Option<u64>,
) -> impl IntoView {
let header_epoch = selected_epoch.unwrap_or(current_epoch);
let next_epoch = header_epoch + 1;
Expand Down Expand Up @@ -120,7 +120,7 @@ pub fn StakesPageContents(
<EpochButton
disabled=prev_epoch_sig
.get()
.map(|prev_epoch| prev_epoch < 0)
.map(|prev_epoch| prev_epoch == 0)
.unwrap_or_default()
text="Previous"
style_variant=EpochStyleVariant::Secondary
Expand Down Expand Up @@ -180,7 +180,7 @@ pub fn StakesPageContents(
#[component]
pub fn EpochButton(
#[prop(into)] text: String,
#[prop(optional)] epoch_target: i64,
#[prop(optional)] epoch_target: u64,
#[prop(default = false)] disabled: bool,
style_variant: EpochStyleVariant,
#[prop(default=String::new(), into)] href: String,
Expand Down
6 changes: 3 additions & 3 deletions src/stakes/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ pub fn get_delegators_count(stake: &StakingLedgersQueryStakes) -> String {
}

pub async fn load_data(
epoch: Option<i64>,
epoch: Option<u64>,
public_key: Option<String>,
delegate: Option<String>,
) -> Result<staking_ledgers_query::ResponseData, MyError> {
let variables = staking_ledgers_query::Variables {
sort_by: staking_ledgers_query::StakeSortByInput::STAKE_DESC,
limit: Some(TABLE_ROW_LIMIT),
limit: Some(TABLE_ROW_LIMIT as i64),
query: staking_ledgers_query::StakeQueryInput {
public_key,
delegate,
epoch,
epoch: Some(epoch.unwrap_or_default() as i64),
..Default::default()
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/stakes/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use leptos_use::{storage::use_local_storage, utils::JsonCodec};

#[component]
pub fn StakesPage() -> impl IntoView {
let (epoch_sig, _) = create_query_signal::<i64>("epoch");
let (epoch_sig, _) = create_query_signal::<u64>("epoch");
let (summary_sig, _, _) =
use_local_storage::<BlockchainSummary, JsonCodec>(BLOCKCHAIN_SUMMARY_STORAGE_KEY);

Expand Down
4 changes: 2 additions & 2 deletions src/summary/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
pub struct BlockchainSummary {
pub blockchain_length: u64,
pub circulating_supply: String,
pub epoch: u32,
pub slot: u32,
pub epoch: u64,
pub slot: u64,
pub global_slot: i64,
pub staking_epoch_ledger_hash: String,
pub total_currency: String,
Expand Down
2 changes: 1 addition & 1 deletion src/tokens/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn generate_random_string(len: usize) -> String {
.collect()
}

pub fn stub_token_data(size: i64) -> Vec<Option<TokenData>> {
pub fn stub_token_data(size: u64) -> Vec<Option<TokenData>> {
let mut rng = rand::thread_rng();
(0..size)
.map(|_| {
Expand Down
2 changes: 1 addition & 1 deletion src/user_commands/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn TransactionsSection() -> impl IntoView {
let (data_sig, set_data) = create_signal(None);
let (txn_type_qp, _) = create_query_signal::<String>(QP_TXN_TYPE);
let query_params_map = use_query_map();
let (block_height_sig, _) = create_query_signal::<i64>(QP_HEIGHT);
let (block_height_sig, _) = create_query_signal::<u64>(QP_HEIGHT);
let UseIntervalReturn { counter, .. } = use_interval(LIVE_RELOAD_INTERVAL);

let resource = create_resource(
Expand Down
8 changes: 4 additions & 4 deletions src/user_commands/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ pub async fn load_pending_txn() -> Result<transactions_query::ResponseData, MyEr
}

pub async fn load_data(
limit: i64,
limit: u64,
from_account: Option<String>,
to_account: Option<String>,
txn_hash: Option<String>,
block_height: Option<i64>,
block_height: Option<u64>,
state_hash: Option<String>,
canonical: Option<bool>,
) -> Result<transactions_query::ResponseData, MyError> {
let variables = transactions_query::Variables {
sort_by: transactions_query::TransactionSortByInput::BLOCKHEIGHT_DESC,
limit: Some(limit),
limit: Some(limit as i64),
txn_query: transactions_query::TransactionQueryInput {
from: from_account,
to: to_account,
hash: txn_hash.clone(),
block_height_lte: block_height,
block_height_lte: Some(block_height.unwrap_or_default() as i64),
canonical,
block: state_hash
.clone()
Expand Down
4 changes: 2 additions & 2 deletions src/user_commands/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct PoolUserCommandReceiver {
pub struct PooledUserCommand {
pub hash: Option<String>,
pub kind: Option<String>,
pub nonce: Option<i64>,
pub nonce: Option<u64>,
pub source: Option<PooledUserCommandSource>,
pub receiver: Option<PoolUserCommandReceiver>,
pub amount: Option<String>,
Expand Down Expand Up @@ -69,7 +69,7 @@ impl From<PooledUserCommand> for transactions_query::TransactionsQueryTransactio
Some(source) => source.public_key,
None => None,
},
nonce: txn.nonce,
nonce: Some(txn.nonce.unwrap_or_default() as i64),
memo: txn.memo,
hash: txn.hash,
block: None,
Expand Down
4 changes: 2 additions & 2 deletions src/zk_apps/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::models::*;
use crate::common::functions::*;
use rand::Rng;

pub fn stub_zk_apps_data(size: i64) -> Vec<Option<ZkAppData>> {
pub fn stub_zk_apps_data(size: u64) -> Vec<Option<ZkAppData>> {
let mut rng = rand::thread_rng();
(0..size)
.map(|_| {
Expand All @@ -17,7 +17,7 @@ pub fn stub_zk_apps_data(size: i64) -> Vec<Option<ZkAppData>> {
.collect()
}

pub fn stub_zk_app_txn_data(size: i64) -> Vec<Option<ZkAppTransactionData>> {
pub fn stub_zk_app_txn_data(size: u64) -> Vec<Option<ZkAppTransactionData>> {
let mut rng = rand::thread_rng();
(0..size)
.map(|_| {
Expand Down
2 changes: 1 addition & 1 deletion src/zk_apps/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn ZkAppSpotlight() -> impl IntoView {
hash: Some("5JunUf7Niybx1d2CdLLZWL1D9wwtce5dBFM7nXsQ9GtiyopSh1Ee".to_string()),
amount: Some(0.01_f64),
date_time: Some(chrono::Utc::now()),
height: Some(5822_i64),
height: Some(5822_u64),
kind: Some("PAYMENT".to_string()),
nonce: Some(1),
failure_reason: None,
Expand Down

0 comments on commit 825c50a

Please sign in to comment.