Skip to content
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

Merge develop #263

Merged
merged 16 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Endpoint to cancel ask and discard the transfer cap in a single tx (#258
)
  • Loading branch information
porkbrain authored Feb 16, 2023
commit 9b8c07b4e9f50d8d17e5f69c5ce30b9b81ed81d6
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
- `create_safe_and_deposit_and_list_nft` (and with commission)
- `create_safe_and_buy_nft`
- `create_safe_and_buy_generic_nft`
- `cancel_ask_and_discard_transfer_cap`
- Added static `name` and `url` fields to `Nft` for better integration with explorer.
- Added `LimitedFixedPriceMarket`
- `orderbook::list_nft` and `orderbook::list_nft_with_commission` endpoints.
Expand Down
28 changes: 24 additions & 4 deletions sources/trading/orderbook.move
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,10 @@ module nft_protocol::orderbook {
ctx: &mut TxContext,
) {
assert!(!book.protected_actions.cancel_ask, err::action_not_public());
cancel_ask_(book, nft_price_level, nft_id, ctx)
transfer(
cancel_ask_(book, nft_price_level, nft_id, ctx),
tx_context::sender(ctx),
);
}

/// Same as [`cancel_ask`] but protected by
Expand All @@ -597,7 +600,24 @@ module nft_protocol::orderbook {
) {
utils::assert_same_module_as_witness<C, W>();

cancel_ask_(book, nft_price_level, nft_id, ctx)
transfer(
cancel_ask_(book, nft_price_level, nft_id, ctx),
tx_context::sender(ctx),
);
}

/// Same as [`cancel_ask`] but the [`TransferCap`] is burned instead of
/// transferred back to the tx sender.
public entry fun cancel_ask_and_discard_transfer_cap<C, FT>(
book: &mut Orderbook<C, FT>,
nft_price_level: u64,
nft_id: ID,
seller_safe: &mut Safe,
ctx: &mut TxContext,
) {
assert!(!book.protected_actions.cancel_ask, err::action_not_public());
let cap = cancel_ask_(book, nft_price_level, nft_id, ctx);
safe::burn_transfer_cap(cap, seller_safe);
}

// === Buy NFT ===
Expand Down Expand Up @@ -1257,7 +1277,7 @@ module nft_protocol::orderbook {
nft_price_level: u64,
nft_id: ID,
ctx: &mut TxContext,
) {
): TransferCap {
let sender = tx_context::sender(ctx);

let Ask {
Expand All @@ -1280,7 +1300,7 @@ module nft_protocol::orderbook {

assert!(owner == sender, err::order_owner_must_be_sender());

transfer(transfer_cap, sender);
transfer_cap
}

fun buy_nft_<C, FT>(
Expand Down