Skip to content

Commit e556e98

Browse files
authored
Merge branch 'dwbs' into undersaturated
2 parents 3e273f9 + be5d6e9 commit e556e98

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/contract.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,20 +566,26 @@ pub fn query_transactions(
566566
let account = Addr::unchecked(account);
567567
let account_raw = deps.api.addr_canonicalize(account.as_str())?;
568568

569+
let start = page * page_size;
570+
569571
// first check if there are any transactions in dwb
570572
let dwb = DWB.load(deps.storage)?;
571573
let dwb_index = dwb.recipient_match(&account_raw);
572-
let mut transactions_in_dwb = vec![];
573-
if dwb_index > 0 && dwb.entries[dwb_index].list_len()? > 0 {
574+
let mut txs_in_dwb = vec![];
575+
let txs_in_dwb_count = dwb.entries[dwb_index].list_len()?;
576+
if dwb_index > 0 && txs_in_dwb_count > 0 && start < txs_in_dwb_count as u32 { // skip if start is after buffer entries
574577
let head_node_index = dwb.entries[dwb_index].head_node()?;
575578
if head_node_index > 0 {
576579
let head_node = TX_NODES.add_suffix(&head_node_index.to_be_bytes()).load(deps.storage)?;
577-
transactions_in_dwb = head_node.to_vec(deps.storage, deps.api)?;
580+
txs_in_dwb = head_node.to_vec(deps.storage, deps.api)?;
578581
}
579582
}
580583

581584
// second get number of txs in account storage
582-
585+
let addr_store = ACCOUNT_TXS.add_suffix(account_raw.as_slice());
586+
let len = addr_store.get_len(deps.storage)? as u64;
587+
588+
583589
/*
584590
let (txs, total) =
585591
StoredTx::get_txs(

0 commit comments

Comments
 (0)