From b6473ca38c2e4e7c1ac9a3e5d60ebf24398412a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=81abor?= Date: Wed, 7 Feb 2024 00:18:38 -0500 Subject: [PATCH] Add `new_custom` --- kiosk/sources/extensions/personal_kiosk.move | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kiosk/sources/extensions/personal_kiosk.move b/kiosk/sources/extensions/personal_kiosk.move index b9ce890..0556cbf 100644 --- a/kiosk/sources/extensions/personal_kiosk.move +++ b/kiosk/sources/extensions/personal_kiosk.move @@ -51,9 +51,20 @@ module kiosk::personal_kiosk { public fun new( kiosk: &mut Kiosk, cap: KioskOwnerCap, ctx: &mut TxContext ): PersonalKioskCap { - assert!(kiosk::has_access(kiosk, &cap), EWrongKiosk); + new_custom(kiosk, cap, sender(ctx), ctx) + } - let owner = sender(ctx); + /// Wrap the KioskOwnerCap making the Kiosk "owned" and non-transferable + /// for a given address. + /// The `PersonalKioskCap` is returned to allow chaining within a PTB, but + /// the value must be consumed by the `transfer_to_sender` call in any case. + public fun new_custom( + kiosk: &mut Kiosk, + cap: KioskOwnerCap, + owner: address, + ctx: &mut TxContext, + ): PersonalKioskCap { + assert!(kiosk::has_access(kiosk, &cap), EWrongKiosk); // set the owner property of the Kiosk kiosk::set_owner(kiosk, &cap, ctx);