-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat(move/examples): implementation of kiosk marketplace extension using kiosk rules #4156
base: develop
Are you sure you want to change the base?
feat(move/examples): implementation of kiosk marketplace extension using kiosk rules #4156
Conversation
… separately from the marketplace extension and added some mock items for marketplace operations
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.
Good example! What do you think about creating a documentation page with the text of the README?
docs/examples/move/nft_marketplace/sources/nft_marketplace.move
Outdated
Show resolved
Hide resolved
docs/examples/move/nft_marketplace/sources/nft_marketplace.move
Outdated
Show resolved
Hide resolved
docs/examples/move/nft_marketplace/sources/nft_marketplace.move
Outdated
Show resolved
Hide resolved
docs/examples/move/nft_marketplace/sources/nft_marketplace.move
Outdated
Show resolved
Hide resolved
docs/examples/move/nft_marketplace/sources/item_for_market.move
Outdated
Show resolved
Hide resolved
Co-authored-by: Mirko Zichichi <[email protected]>
✅ Vercel Preview Deployment is ready! |
✅ Vercel Preview Deployment is ready! |
✅ Vercel Preview Deployment is ready! |
docs/examples/move/nft_marketplace/sources/nft_marketplace.move
Outdated
Show resolved
Hide resolved
Co-authored-by: Mirko Zichichi <[email protected]>
Co-authored-by: Mirko Zichichi <[email protected]>
✅ Vercel Preview Deployment is ready! |
assert!(kiosk_extension::is_installed<Marketplace>(kiosk), EExtensionNotInstalled); | ||
let ItemPrice { price } = take_from_bag<T, Listed>(kiosk, Listed { id: item_id }); | ||
|
||
let payment_amount_value = payment.value(); | ||
let coin_price = payment.split(price, ctx); | ||
|
||
let (item, mut transfer_request) = purchase(kiosk, item_id, coin_price); | ||
if (policy.has_rule<T, RoyaltyRule>()) { | ||
let royalties_value = royalty_rule::fee_amount(policy, price); | ||
assert!(payment_amount_value == price + royalties_value, EWrongPaymentRoyalties); | ||
royalty_rule::pay(policy, &mut transfer_request, payment); | ||
} else { | ||
payment.destroy_zero(); | ||
}; | ||
transfer_policy::confirm_request(policy, transfer_request); |
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.
assert!(kiosk_extension::is_installed<Marketplace>(kiosk), EExtensionNotInstalled); | |
let ItemPrice { price } = take_from_bag<T, Listed>(kiosk, Listed { id: item_id }); | |
let payment_amount_value = payment.value(); | |
let coin_price = payment.split(price, ctx); | |
let (item, mut transfer_request) = purchase(kiosk, item_id, coin_price); | |
if (policy.has_rule<T, RoyaltyRule>()) { | |
let royalties_value = royalty_rule::fee_amount(policy, price); | |
assert!(payment_amount_value == price + royalties_value, EWrongPaymentRoyalties); | |
royalty_rule::pay(policy, &mut transfer_request, payment); | |
} else { | |
payment.destroy_zero(); | |
}; | |
transfer_policy::confirm_request(policy, transfer_request); | |
assert!(kiosk_extension::is_installed<Marketplace>(kiosk), EExtensionNotInstalled); | |
// Get item price | |
let ItemPrice { price } = take_from_bag<T, Listed>(kiosk, Listed { id: item_id }); | |
// Compute the value of the coin in input | |
let payment_amount_value = payment.value(); | |
// Prepare the payment coin for the purchase (if no royalties are present then the | |
// remaining balance will be 0 after this operation) | |
let coin_price = payment.split(price, ctx); | |
// Purchase and create the transfer request | |
let (item, mut transfer_request) = purchase(kiosk, item_id, coin_price); | |
// If the royalty is present, then update the request with a royalty payment | |
if (policy.has_rule<T, RoyaltyRule>()) { | |
let royalties_value = royalty_rule::fee_amount(policy, price); | |
assert!(payment_amount_value == price + royalties_value, EWrongPaymentRoyalties); | |
royalty_rule::pay(policy, &mut transfer_request, payment); | |
} else { | |
// Else clean the input coin (if the input payment amount is not exact, this will fail) | |
payment.destroy_zero(); | |
}; | |
// Confirm the request | |
transfer_policy::confirm_request(policy, transfer_request); |
Description of change
New Kiosk extensions have been added in order to demonstrate practical usage of some Kiosk features(extensions, rules, transfer policies).
Links to any relevant issues
Fix #3997 .
Type of change
How the change has been tested
Read https://github.com/iotaledger/iota/pull/4156/files#diff-ed4b688332b92ef7cc237545e28cac0a73f64d2e509737d8e95cc72a6b82831d