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(local-blockchain.ts): reverse order of events #1460

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- `transaction.hash()` is no longer a function, it is now a property that returns the hash of the transaction.
- Improved efficiency of computing `AccountUpdate.callData` by packing field elements into as few field elements as possible https://github.com/o1-labs/o1js/pull/1458
- This leads to a large reduction in the number of constraints used when inputs to a zkApp method are many field elements (e.g. a long list of `Bool`s)
- Return events in the `LocalBlockchain` in reverse chronological order (latest events at the beginning) to match the behavior of the `Network` https://github.com/o1-labs/o1js/pull/1460

### Added

Expand Down
6 changes: 5 additions & 1 deletion src/lib/mina/local-blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,11 @@ function LocalBlockchain({
);
},
async fetchEvents(publicKey: PublicKey, tokenId: Field = TokenId.default) {
return events?.[publicKey.toBase58()]?.[TokenId.toBase58(tokenId)] ?? [];
// Return events in reverse chronological order (latest events at the beginning)
const reversedEvents = (
events?.[publicKey.toBase58()]?.[TokenId.toBase58(tokenId)] ?? []
).reverse();
return reversedEvents;
},
async fetchActions(
publicKey: PublicKey,
Expand Down