-
Notifications
You must be signed in to change notification settings - Fork 122
Unlimited and timed fungible faucets ( supply related ) #2459
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0979b41
Add support for unlimited and timed fungible faucets
afa7789 f057b83
feat: update procedures for timed and unlimited fungible faucets with…
afa7789 98a0d09
feat: enhance supply management with improved error handling and meta…
afa7789 135d552
Refactor supply management in fungible faucet contracts
afa7789 7386db3
Refactor supply management for fungible faucets
afa7789 4ad9388
feat: enhance error handling in fungible faucet components and improv…
afa7789 4466e82
feat: integrate supply limits checks in fungible faucet contracts and…
afa7789 e0b0afc
feat: add Timed Unlimited Fungible Faucet component with distribution…
afa7789 1270c23
refactor: simplify supply checks in distribute procedure and remove r…
afa7789 7e1d333
refactor: streamline supply checks and error handling in fungible fau…
afa7789 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
crates/miden-standards/asm/account_components/faucets/timed_fungible_faucet.masm
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # The MASM code of the Timed Fungible Faucet Account Component. | ||
| # | ||
| # See the `TimedFungibleFaucet` Rust type's documentation for more details. | ||
|
|
||
| pub use ::miden::standards::faucets::timed_fungible::distribute | ||
| pub use ::miden::standards::faucets::timed_fungible::burn | ||
| pub use ::miden::standards::faucets::timed_fungible::transfer_ownership | ||
| pub use ::miden::standards::faucets::timed_fungible::renounce_ownership |
4 changes: 4 additions & 0 deletions
4
crates/miden-standards/asm/account_components/faucets/timed_unlimited_fungible_faucet.masm
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| pub use ::miden::standards::faucets::timed_unlimited_fungible::distribute | ||
| pub use ::miden::standards::faucets::timed_unlimited_fungible::burn | ||
| pub use ::miden::standards::faucets::timed_unlimited_fungible::transfer_ownership | ||
| pub use ::miden::standards::faucets::timed_unlimited_fungible::renounce_ownership |
8 changes: 8 additions & 0 deletions
8
crates/miden-standards/asm/account_components/faucets/unlimited_fungible_faucet.masm
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # The MASM code of the Unlimited Fungible Faucet Account Component. | ||
| # | ||
| # See the `UnlimitedFungibleFaucet` Rust type's documentation for more details. | ||
|
|
||
| pub use ::miden::standards::faucets::unlimited_fungible::distribute | ||
| pub use ::miden::standards::faucets::unlimited_fungible::burn | ||
| pub use ::miden::standards::faucets::unlimited_fungible::transfer_ownership | ||
| pub use ::miden::standards::faucets::unlimited_fungible::renounce_ownership |
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
70 changes: 70 additions & 0 deletions
70
crates/miden-standards/asm/standards/faucets/timed_fungible.masm
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # TIMED SUPPLY FUNGIBLE FAUCET CONTRACT | ||
| # | ||
| # A fungible faucet with time-based distribution controls. | ||
| # This faucet enforces a distribution period for minting. | ||
| # Burns are always allowed. Supply tracking is handled by faucets::distribute/burn. | ||
| # ================================================================================================= | ||
|
|
||
| use miden::standards::faucets | ||
| use miden::standards::access::ownable | ||
| use miden::standards::supply::supply_limits | ||
|
|
||
| # OWNER MANAGEMENT | ||
| # ================================================================================================= | ||
|
|
||
| pub use ownable::get_owner | ||
| pub use ownable::transfer_ownership | ||
| pub use ownable::renounce_ownership | ||
|
|
||
| # PROCEDURES | ||
| # ================================================================================================= | ||
|
|
||
| #! Distributes freshly minted fungible assets to the provided recipient by creating a note. | ||
| #! | ||
| #! This procedure checks the distribution period before delegating to the shared distribute | ||
| #! procedure which handles supply tracking in the metadata slot. | ||
| #! | ||
| #! Inputs: [amount, tag, note_type, RECIPIENT] | ||
| #! Outputs: [note_idx] | ||
| #! | ||
| #! Where: | ||
| #! - amount is the amount to be minted and sent. | ||
| #! - tag is the tag to be included in the note. | ||
| #! - note_type is the type of the note that holds the asset. | ||
| #! - RECIPIENT is the recipient of the asset, i.e., | ||
| #! hash(hash(hash(serial_num, [0; 4]), script_root), storage_commitment). | ||
| #! - note_idx is the index of the created note. | ||
| #! | ||
| #! Panics if: | ||
| #! - the transaction is being executed against an account that is not a fungible asset faucet. | ||
| #! - the note sender is not the owner of this faucet. | ||
| #! - the distribution period has ended. | ||
| #! | ||
| #! Invocation: exec | ||
| pub proc distribute | ||
| exec.ownable::verify_owner | ||
|
|
||
| exec.supply_limits::check_distribution_period | ||
| # => [amount, tag, note_type, RECIPIENT] | ||
|
|
||
| exec.faucets::distribute | ||
| # => [note_idx] | ||
| end | ||
|
|
||
| #! Burns the fungible asset from the active note. | ||
| #! | ||
| #! Burns are always allowed — no time or ownership restrictions. | ||
| #! Delegates to the shared burn procedure which handles supply tracking. | ||
| #! | ||
| #! Inputs: [pad(16)] | ||
| #! Outputs: [pad(16)] | ||
| #! | ||
| #! Panics if: | ||
| #! - the procedure is not called from a note context. | ||
| #! - the note does not contain exactly one asset. | ||
| #! - the transaction is executed against an account which is not a fungible asset faucet. | ||
| #! - the transaction is executed against a faucet which is not the origin of the specified asset. | ||
| #! - the amount to burn exceeds the current token supply. | ||
| #! | ||
| #! Invocation: call | ||
| pub use faucets::burn |
72 changes: 72 additions & 0 deletions
72
crates/miden-standards/asm/standards/faucets/timed_unlimited_fungible.masm
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # TIMED UNLIMITED SUPPLY FUNGIBLE FAUCET CONTRACT | ||
| # | ||
| # A fungible faucet with time-based distribution controls but no supply cap. | ||
| # This faucet enforces a distribution period for minting, with max_supply set | ||
| # to FUNGIBLE_ASSET_MAX_AMOUNT (effectively unlimited). | ||
| # Burns are always allowed. Supply tracking is handled by faucets::distribute/burn. | ||
| # ================================================================================================= | ||
|
|
||
| use miden::standards::faucets | ||
| use miden::standards::access::ownable | ||
| use miden::standards::supply::supply_limits | ||
|
|
||
| # OWNER MANAGEMENT | ||
| # ================================================================================================= | ||
|
|
||
| pub use ownable::get_owner | ||
| pub use ownable::transfer_ownership | ||
| pub use ownable::renounce_ownership | ||
|
|
||
| # PROCEDURES | ||
| # ================================================================================================= | ||
|
|
||
| #! Distributes freshly minted fungible assets to the provided recipient by creating a note. | ||
| #! | ||
| #! This procedure checks the distribution period before delegating to the shared distribute | ||
| #! procedure which handles supply tracking in the metadata slot. | ||
| #! No supply cap is enforced — max_supply is set to FUNGIBLE_ASSET_MAX_AMOUNT at creation. | ||
| #! | ||
| #! Inputs: [amount, tag, note_type, RECIPIENT] | ||
| #! Outputs: [note_idx] | ||
| #! | ||
| #! Where: | ||
| #! - amount is the amount to be minted and sent. | ||
| #! - tag is the tag to be included in the note. | ||
| #! - note_type is the type of the note that holds the asset. | ||
| #! - RECIPIENT is the recipient of the asset, i.e., | ||
| #! hash(hash(hash(serial_num, [0; 4]), script_root), storage_commitment). | ||
| #! - note_idx is the index of the created note. | ||
| #! | ||
| #! Panics if: | ||
| #! - the transaction is being executed against an account that is not a fungible asset faucet. | ||
| #! - the note sender is not the owner of this faucet. | ||
| #! - the distribution period has ended. | ||
| #! | ||
| #! Invocation: exec | ||
| pub proc distribute | ||
| exec.ownable::verify_owner | ||
|
|
||
| exec.supply_limits::check_distribution_period | ||
| # => [amount, tag, note_type, RECIPIENT] | ||
|
|
||
| exec.faucets::distribute | ||
| # => [note_idx] | ||
| end | ||
|
|
||
| #! Burns the fungible asset from the active note. | ||
| #! | ||
| #! Burns are always allowed — no time or ownership restrictions. | ||
| #! Delegates to the shared burn procedure which handles supply tracking. | ||
| #! | ||
| #! Inputs: [pad(16)] | ||
| #! Outputs: [pad(16)] | ||
| #! | ||
| #! Panics if: | ||
| #! - the procedure is not called from a note context. | ||
| #! - the note does not contain exactly one asset. | ||
| #! - the transaction is executed against an account which is not a fungible asset faucet. | ||
| #! - the transaction is executed against a faucet which is not the origin of the specified asset. | ||
| #! - the amount to burn exceeds the current token supply. | ||
| #! | ||
| #! Invocation: call | ||
| pub use faucets::burn |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only glanced through this PR, but I wonder if the approach should be more along the lines I described in OpenZeppelin/miden-confidential-contracts#39 (reply in thread). Basically, we have a single network fungible faucet component, but we can customize mint policies using procedures stored in account storage. These policies could be under
miden::standards::faucet::network_fungible::mint_policiesor something like that.