import type { Transaction, TransactionArgument, TransactionObjectArgument } from '@iota/iota-sdk/transactions'; import type { ItemId, ItemReference, ItemValue, KioskOwnerCap, ObjectArgument, Price, PurchaseOptions } from '../types/index.js'; import type { KioskClient } from './kiosk-client.js'; export type KioskTransactionParams = { /** The Transaction for this run */ transaction: Transaction; /** @deprecated use transaction instead */ transactionBlock?: Transaction; /** * You can create a new KioskClient by calling `new KioskClient()` */ kioskClient: KioskClient; /** * You can optionally pass in the `cap` as returned * from `kioskClient.getOwnedKiosks` when initializing the client * Otherwise, you can set it by calling `kioskTransaction.setCap()` */ cap?: KioskOwnerCap; }; /** * A helper for building transactions that involve kiosk. */ export declare class KioskTransaction { #private; transaction: Transaction; kioskClient: KioskClient; kiosk?: TransactionObjectArgument; kioskCap?: TransactionObjectArgument; constructor({ transactionBlock, transaction, kioskClient, cap, }: KioskTransactionParams); /** * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state. * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address. * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions. */ create(): this; /** * Creates a personal kiosk & shares it. * The `PersonalKioskCap` is transferred to the signer. * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions. */ createPersonal(borrow?: boolean): this; /** * Converts a kiosk to a Personal (Soulbound) Kiosk. * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`. */ convertToPersonal(borrow?: boolean): this; /** * Single function way to create a kiosk, share it and transfer the cap to the specified address. */ createAndShare(address: string): void; /** * Shares the kiosk. */ share(): void; /** * Should be called only after `create` is called. * It shares the kiosk & transfers the cap to the specified address. */ shareAndTransferCap(address: string): void; /** * A function to borrow an item from a kiosk & execute any function with it. */ borrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void): void; /** * Borrows an item from the kiosk. * This will fail if the item is listed for sale. * * Requires calling `return`. */ borrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument]; /** * Returns the item back to the kiosk. * Accepts the parameters returned from the `borrow` function. */ return({ itemType, item, promise }: ItemValue & { promise: TransactionArgument; }): this; /** * A function to withdraw from kiosk * @param address Where to transfer the coin. * @param amount The amount we aim to withdraw. */ withdraw(address: string, amount?: string | bigint | number): this; /** * A function to place an item in the kiosk. * @param itemType The type `T` of the item * @param item The ID or Transaction Argument of the item */ place({ itemType, item }: ItemReference): this; /** * A function to place an item in the kiosk and list it for sale in one transaction. * @param itemType The type `T` of the item * @param item The ID or Transaction Argument of the item * @param price The price in NANOS */ placeAndList({ itemType, item, price }: ItemReference & Price): this; /** * A function to list an item in the kiosk. * @param itemType The type `T` of the item * @param itemId The ID of the item * @param price The price in NANOS */ list({ itemType, itemId, price }: ItemId & { price: string | bigint; }): this; /** * A function to delist an item from the kiosk. * @param itemType The type `T` of the item * @param itemId The ID of the item */ delist({ itemType, itemId }: ItemId): this; /** * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked. * @param itemType The type `T` of the item * @param itemId The ID of the item */ take({ itemType, itemId }: ItemId): TransactionObjectArgument; /** * Transfer a non-locked/non-listed item to an address. * * @param itemType The type `T` of the item * @param itemId The ID of the item * @param address The destination address */ transfer({ itemType, itemId, address }: ItemId & { address: string; }): this; /** * A function to take lock an item in the kiosk. * @param itemType The type `T` of the item * @param item The ID or Transaction Argument of the item * @param itemId The ID of the item - Deprecated: Use `item` instead. * @param policy The Policy ID or Transaction Argument for item T */ lock({ itemType, item, itemId, policy, }: ItemReference & { policy: ObjectArgument; itemId?: string; }): this; /** * Purchase an item from a seller's kiosk. * Returns [item, transferRequest] * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})` * @param itemType The type `T` of the item * @param itemId The ID of the item * @param price The price in NANOS * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument. */ purchase({ itemType, itemId, price, sellerKiosk, }: ItemId & Price & { sellerKiosk: ObjectArgument; }): [ TransactionObjectArgument, TransactionObjectArgument ]; /** * A function to purchase and resolve a transfer policy. * If the transfer policy has the `lock` rule, the item is locked in the kiosk. * Otherwise, the item is placed in the kiosk. * @param itemType The type of the item * @param itemId The id of the item * @param price The price of the specified item * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument. * @param extraArgs Used to pass arguments for custom rule resolvers. */ purchaseAndResolve({ itemType, itemId, price, sellerKiosk, extraArgs, }: ItemId & Price & { sellerKiosk: ObjectArgument; } & PurchaseOptions): Promise; /** * A function to setup the client using an existing `ownerCap`, * as return from the `kioskClient.getOwnedKiosks` function. * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call. */ setCap(cap: KioskOwnerCap): this | undefined; /** * A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the * `PersonalKioskCap`, in case we are operating on a personal kiosk. * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending. */ finalize(): void; setKioskCap(cap: TransactionObjectArgument): this; setKiosk(kiosk: TransactionObjectArgument): this; getKiosk(): TransactionObjectArgument; getKioskCap(): TransactionObjectArgument; }