Class: KioskTransaction
A helper for building transactions that involve kiosk.
Constructors
Constructor
new KioskTransaction(__namedParameters): KioskTransaction;
Parameters
| Parameter | Type |
|---|---|
__namedParameters | KioskTransactionParams |
Returns
KioskTransaction
Properties
| Property | Type |
|---|---|
transaction | Transaction |
kioskClient | KioskClient |
kiosk? | TransactionObjectArgument |
kioskCap? | TransactionObjectArgument |
Methods
create()
create(): KioskTransaction;
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.
Returns
KioskTransaction
createPersonal()
createPersonal(borrow?): KioskTransaction;
Creates a personal kiosk & shares it.
The PersonalKioskCap is transferred to the signer.
Parameters
| Parameter | Type | Description |
|---|---|---|
borrow? | boolean | If true, the kioskOwnerCap is borrowed from the PersonalKioskCap to be used in next transactions. |
Returns
KioskTransaction
convertToPersonal()
convertToPersonal(borrow?): KioskTransaction;
Converts a kiosk to a Personal (Soulbound) Kiosk.
Requires initialization by either calling ktxb.create() or ktxb.setCap().
Parameters
| Parameter | Type |
|---|---|
borrow? | boolean |
Returns
KioskTransaction
createAndShare()
createAndShare(address): void;
Single function way to create a kiosk, share it and transfer the cap to the specified address.
Parameters
| Parameter | Type |
|---|---|
address | string |
Returns
void
share()
share(): void;
Shares the kiosk.
Returns
void
shareAndTransferCap()
shareAndTransferCap(address): void;
Should be called only after create is called.
It shares the kiosk & transfers the cap to the specified address.
Parameters
| Parameter | Type |
|---|---|
address | string |
Returns
void
borrowTx()
borrowTx(__namedParameters, callback): void;
A function to borrow an item from a kiosk & execute any function with it.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | ItemId |
callback | (item) => void |
Returns
void
borrow()
borrow(__namedParameters): [TransactionArgument, TransactionArgument];
Borrows an item from the kiosk. This will fail if the item is listed for sale.
Requires calling return.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | ItemId |
Returns
[TransactionArgument, TransactionArgument]
return()
return(__namedParameters): KioskTransaction;
Returns the item back to the kiosk.
Accepts the parameters returned from the borrow function.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | ItemValue & object |
Returns
KioskTransaction
withdraw()
withdraw(address, amount?): KioskTransaction;
A function to withdraw from kiosk
Parameters
| Parameter | Type | Description |
|---|---|---|
address | string | Where to transfer the coin. |
amount? | string | number | bigint | The amount we aim to withdraw. |
Returns
KioskTransaction
place()
place(itemType): KioskTransaction;
A function to place an item in the kiosk.
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemReference | The type T of the item |
Returns
KioskTransaction
placeAndList()
placeAndList(itemType): KioskTransaction;
A function to place an item in the kiosk and list it for sale in one transaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemReference & Price | The type T of the item |
Returns
KioskTransaction
list()
list(itemType): KioskTransaction;
A function to list an item in the kiosk.
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemId & object | The type T of the item |
Returns
KioskTransaction
delist()
delist(itemType): KioskTransaction;
A function to delist an item from the kiosk.
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemId | The type T of the item |
Returns
KioskTransaction
take()
take(itemType): TransactionObjectArgument;
A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemId | The type T of the item |
Returns
TransactionObjectArgument
transfer()
transfer(itemType): KioskTransaction;
Transfer a non-locked/non-listed item to an address.
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemId & object | The type T of the item |
Returns
KioskTransaction
lock()
lock(itemType): KioskTransaction;
A function to take lock an item in the kiosk.
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemReference & object | The type T of the item |
Returns
KioskTransaction
purchase()
purchase(itemType): [TransactionObjectArgument, TransactionObjectArgument];
Purchase an item from a seller's kiosk.
Returns [item, transferRequest]
Can be called like: const [item, transferRequest] = kioskTx.purchase({...})
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemId & Price & object | The type T of the item |
Returns
[TransactionObjectArgument, TransactionObjectArgument]
purchaseAndResolve()
purchaseAndResolve(itemType): Promise<KioskTransaction>;
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.
Parameters
| Parameter | Type | Description |
|---|---|---|
itemType | ItemId & Price & object & PurchaseOptions | The type of the item |
Returns
Promise<KioskTransaction>
setCap()
setCap(cap): KioskTransaction | undefined;
A function to setup the client using an existing ownerCap,
as return from the kioskClient.getOwnedKiosks function.
Parameters
| Parameter | Type | Description |
|---|---|---|
cap | KioskOwnerCap | KioskOwnerCap object as returned from getOwnedKiosks SDK call. |
Returns
KioskTransaction | undefined
finalize()
finalize(): void;
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.
Returns
void
setKioskCap()
setKioskCap(cap): KioskTransaction;
Parameters
| Parameter | Type |
|---|---|
cap | TransactionObjectArgument |
Returns
KioskTransaction
setKiosk()
setKiosk(kiosk): KioskTransaction;
Parameters
| Parameter | Type |
|---|---|
kiosk | TransactionObjectArgument |
Returns
KioskTransaction
getKiosk()
getKiosk(): TransactionObjectArgument;
Returns
TransactionObjectArgument
getKioskCap()
getKioskCap(): TransactionObjectArgument;
Returns
TransactionObjectArgument