Draft
Conversation
6a86ed0 to
716997b
Compare
716997b to
5f014e0
Compare
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.
Adds a storage example demonstrating storage singletons, struct storage, vector storage, and external storage access in Leo 4.
What's in the example
Two programs that together showcase on-chain storage and cross-program reads:
treasury.aleo— Declares and manages on-chain state using Leo 4 storage variables:storage balance: u64,storage is_frozen: bool,storage deposit_count: u32storage config: FeeConfig— stored and read atomicallystorage deposit_log: [u64]— dynamically-sized on-chain list withpush,pop,get,len,clearunwrap/unwrap_orfor reading optional slots,noneassignment for clearing, and theFinalreturn typeauditor.aleo— Reads treasury storage externally without any getter functions:treasury.aleo::balance.unwrap_or(0u64)treasury.aleo::config.unwrap_or(treasury.aleo::FeeConfig { ... })treasury.aleo::deposit_log.len(),treasury.aleo::deposit_log.get(0u32)treasury.aleo::FeeConfigHow to run
run.shhandles the full flow:leo devnode): deploys both programs, performs treasury operations on-chain, then runs auditor functions that read treasury storage cross-program — including detecting a treasury freeze