-
Notifications
You must be signed in to change notification settings - Fork 38
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
Mint hooks #612
Merged
Merged
Mint hooks #612
Conversation
This file contains 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
Codecov ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #612 +/- ##
==========================================
- Coverage 59.20% 58.12% -1.09%
==========================================
Files 80 82 +2
Lines 4246 4325 +79
==========================================
Hits 2514 2514
- Misses 1732 1811 +79
☔ View full report in Codecov by Sentry. |
Cosm-Orc Gas UsageNo gas diff larger than 0.5% Raw Report for ba84d73
|
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.
Mint hooks are a way to extend minters by running custom code before and after minting. Creators may write custom hooks to perform tasks such as implementing burn-to-mint. If a hook fails, the entire transaction is rolled back, so this can be used for pre-mint gating.
Hooks can also be chained together to implement composite actions. For example if you want to burn an NFT while requiring 5000 STARS to be staked, you can chain together a burn-to-mint pre-mint hook and a staked tokens pre-mint hook.
For example, a pre-mint hook could receive an NFT and check if its in the collection to be burned. Then after the mint is complete, the post-mint hook could do the actual burn operation.
The pre-mint action, mint, and post-mint actions are sub-messages that are implemented as a single atomic action. They are executed in order, and all rollback if one of them fails.
Macros are provided to easily add this functionality to any minter. This hasn't been added to any minter yet as it depends on
cw-ownable
being added to minters. However, work is ongoing at #611.For Creators: How to add a hook
AddPreMintHook { hook }
orAddPostMintHook { hook }
for each hook.For Devs: How to add mint hooks to a minter contract
Add macros for execute and query enums
Add the pre and post submessages to mint execution
Handle the reply errors