Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zcoin): impl tx_history support for WASM target #2077

Merged
merged 16 commits into from
Mar 29, 2024
Merged

Conversation

borngraced
Copy link
Member

@borngraced borngraced commented Mar 4, 2024

fixes: #2072

Screenshot 2024-03-18 at 05 06 48

@borngraced borngraced added the in progress Changes will be made from the author label Mar 4, 2024
@borngraced borngraced self-assigned this Mar 4, 2024
@borngraced borngraced added under review and removed in progress Changes will be made from the author labels Mar 13, 2024
@borngraced borngraced linked an issue Mar 19, 2024 that may be closed by this pull request
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks you for the PR! First review iteration!

mm2src/mm2_main/src/wasm_tests.rs Outdated Show resolved Hide resolved
mm2src/coins/z_coin.rs Show resolved Hide resolved
mm2src/coins/z_coin/z_coin_errors.rs Outdated Show resolved Hide resolved
mm2src/coins/z_coin/z_tx_history.rs Outdated Show resolved Hide resolved
mm2src/coins/z_coin/z_tx_history.rs Show resolved Hide resolved
mm2src/coins/z_coin/z_tx_history.rs Show resolved Hide resolved
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Collaborator

@mariocynicys mariocynicys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question, LGTM otherwise :)

Comment on lines +61 to +98
// Fetch transactions
let txs = tx_table
.cursor_builder()
.only("ticker", z.ticker())?
.offset(offset as u32)
.limit(limit)
.reverse()
.open_cursor("ticker")
.await?
.collect()
.await?;

// Fetch received notes
let rn_table = db_transaction.table::<WalletDbReceivedNotesTable>().await?;
let received_notes = rn_table
.cursor_builder()
.only("ticker", z.ticker())?
.open_cursor("ticker")
.await?
.collect()
.await?;

// Fetch blocks
let blocks_table = db_transaction.table::<WalletDbBlocksTable>().await?;
let blocks = blocks_table
.cursor_builder()
.only("ticker", z.ticker())?
.open_cursor("ticker")
.await?
.collect()
.await?;

// Process transactions and construct tx_details
let mut tx_details = vec![];
for (tx_id, tx) in txs {
if let Some((_, WalletDbBlocksTable { height, time, .. })) = blocks
.iter()
.find(|(_, block)| tx.block.map(|b| b == block.height).unwrap_or_default())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: idb doesn't have a join construct like sql?
will such a join ever be expensive?

Copy link
Member Author

@borngraced borngraced Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately indexeddb doesn't offer such abstraction most things are down manually with indexeddb 😄 but with indexes they're fast

@shamardy shamardy merged commit 8a0e195 into dev Mar 29, 2024
24 of 30 checks passed
@shamardy shamardy deleted the zcoin_tx_history branch March 29, 2024 13:59
dimxy added a commit to dimxy/komodo-defi-framework that referenced this pull request Mar 30, 2024
* dev:
  feat(zcoin): balance event streaming (KomodoPlatform#2076)
  feat(zcoin): tx_history support for WASM target (KomodoPlatform#2077)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement z_coin tx_history for WASM target
3 participants