Skip to content

Commit

Permalink
Merge pull request o1-labs#1460 from o1-labs/feat/reverse-events-local
Browse files Browse the repository at this point in the history
feat(local-blockchain.ts): reverse order of events
  • Loading branch information
MartinMinkov authored Feb 23, 2024
2 parents e76ca45 + fd5a7b1 commit 451e734
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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

0 comments on commit 451e734

Please sign in to comment.