From a922d89e4e64b765b7043f5f5a7a6478cf47e5f8 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Fri, 23 Feb 2024 11:37:50 -0800 Subject: [PATCH 1/2] feat(local-blockchain.ts): reverse order of events fetched to display latest events first for better user experience --- src/lib/mina/local-blockchain.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/mina/local-blockchain.ts b/src/lib/mina/local-blockchain.ts index 06dbf6691..852abf34a 100644 --- a/src/lib/mina/local-blockchain.ts +++ b/src/lib/mina/local-blockchain.ts @@ -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, From fd5a7b1882c2925567935d7362aa043cc0f121c4 Mon Sep 17 00:00:00 2001 From: Martin Minkov Date: Fri, 23 Feb 2024 11:39:17 -0800 Subject: [PATCH 2/2] feat(CHANGELOG.md): return events in LocalBlockchain in reverse chronological order to match Network behavior --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07f9ad9c5..db8400ad2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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