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

[kiosk] Kiosk+ (again) #9709

Merged
merged 16 commits into from
Mar 24, 2023
Prev Previous commit
Next Next commit
adds has_item to kiosk
  • Loading branch information
damirka committed Mar 24, 2023
commit 6d3842748e66062afd906346a4aff465892cff1e
26 changes: 26 additions & 0 deletions crates/sui-framework/docs/kiosk.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ be used to implement application-specific transfer rules.
- [Function `purchase_with_cap`](#0x2_kiosk_purchase_with_cap)
- [Function `return_purchase_cap`](#0x2_kiosk_return_purchase_cap)
- [Function `withdraw`](#0x2_kiosk_withdraw)
- [Function `has_item`](#0x2_kiosk_has_item)
- [Function `has_access`](#0x2_kiosk_has_access)
- [Function `uid_mut_as_owner`](#0x2_kiosk_uid_mut_as_owner)
- [Function `uid_mut`](#0x2_kiosk_uid_mut)
Expand Down Expand Up @@ -954,6 +955,31 @@ Withdraw profits from the Kiosk.



</details>

<a name="0x2_kiosk_has_item"></a>

## Function `has_item`

Check whether the an <code>item</code> is present in the <code><a href="kiosk.md#0x2_kiosk_Kiosk">Kiosk</a></code>.


<pre><code><b>public</b> <b>fun</b> <a href="kiosk.md#0x2_kiosk_has_item">has_item</a>(self: &<a href="kiosk.md#0x2_kiosk_Kiosk">kiosk::Kiosk</a>, item_id: <a href="object.md#0x2_object_ID">object::ID</a>): bool
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="kiosk.md#0x2_kiosk_has_item">has_item</a>(self: &<a href="kiosk.md#0x2_kiosk_Kiosk">Kiosk</a>, item_id: ID): bool {
dof::exists_(&self.id, <a href="kiosk.md#0x2_kiosk_Item">Item</a> { id: item_id })
}
</code></pre>



</details>

<a name="0x2_kiosk_has_access"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ module sui::kiosk {

// === Kiosk fields access ===

/// Check whether the an `item` is present in the `Kiosk`.
public fun has_item(self: &Kiosk, item_id: ID): bool {
dof::exists_(&self.id, Item { id: item_id })
}

/// Check whether the `KioskOwnerCap` matches the `Kiosk`.
public fun has_access(self: &mut Kiosk, cap: &KioskOwnerCap): bool {
object::id(self) == cap.for
Expand Down