fix(stream): emit storage_version in the created event (#462) - #494
Open
Abba073 wants to merge 1 commit into
Open
fix(stream): emit storage_version in the created event (#462)#494Abba073 wants to merge 1 commit into
Abba073 wants to merge 1 commit into
Conversation
…col#462) An indexer can now read which storage layout a stream was initialized under directly from the created event, without a separate storage read. - events::created gains a storage_version: u32 parameter appended to the data tuple: (recipient, token, rate_per_second, start_time, end_time, storage_version) - initialize() passes storage::CURRENT_STORAGE_VERSION to events::created
|
@Abba073 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #462.
An indexer can now determine which storage layout a stream was initialized under directly from the
createdevent, without issuing a separatestorage_version()read.Changes
contracts/stream/src/events.rsstorage_version: u32as the final parameter ofevents::created.(recipient, token, rate_per_second, start_time, end_time, storage_version)contracts/stream/src/lib.rsinitialize()now passesstorage::CURRENT_STORAGE_VERSIONas the new argument.Why this approach
storage_versionis already written to instance storage ininitialize()(keyDataKey::StorageVersion). Emitting it in the samecreatedevent is the minimal, zero-cost change that lets indexers avoid the extra cross-contract read — the value is already in scope at the exact point the event fires.What was not changed
createdevent data tuple (only a comment referencesstream_events[0]), so no test updates were needed.