@iota/kiosk 0.0.0-dev-20251015065834

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +198 -0
  2. package/LICENSE +201 -0
  3. package/README.md +39 -0
  4. package/dist/cjs/bcs.d.ts +38 -0
  5. package/dist/cjs/bcs.js +49 -0
  6. package/dist/cjs/bcs.js.map +7 -0
  7. package/dist/cjs/client/kiosk-client.d.ts +76 -0
  8. package/dist/cjs/client/kiosk-client.js +126 -0
  9. package/dist/cjs/client/kiosk-client.js.map +7 -0
  10. package/dist/cjs/client/kiosk-transaction.d.ts +185 -0
  11. package/dist/cjs/client/kiosk-transaction.js +473 -0
  12. package/dist/cjs/client/kiosk-transaction.js.map +7 -0
  13. package/dist/cjs/client/tp-transaction.d.ts +114 -0
  14. package/dist/cjs/client/tp-transaction.js +312 -0
  15. package/dist/cjs/client/tp-transaction.js.map +7 -0
  16. package/dist/cjs/constants.d.ts +24 -0
  17. package/dist/cjs/constants.js +66 -0
  18. package/dist/cjs/constants.js.map +7 -0
  19. package/dist/cjs/index.d.ts +6 -0
  20. package/dist/cjs/index.js +24 -0
  21. package/dist/cjs/index.js.map +7 -0
  22. package/dist/cjs/package.json +5 -0
  23. package/dist/cjs/query/kiosk.d.ts +14 -0
  24. package/dist/cjs/query/kiosk.js +129 -0
  25. package/dist/cjs/query/kiosk.js.map +7 -0
  26. package/dist/cjs/query/transfer-policy.d.ts +29 -0
  27. package/dist/cjs/query/transfer-policy.js +94 -0
  28. package/dist/cjs/query/transfer-policy.js.map +7 -0
  29. package/dist/cjs/tx/kiosk.d.ts +71 -0
  30. package/dist/cjs/tx/kiosk.js +130 -0
  31. package/dist/cjs/tx/kiosk.js.map +7 -0
  32. package/dist/cjs/tx/personal-kiosk.d.ts +7 -0
  33. package/dist/cjs/tx/personal-kiosk.js +38 -0
  34. package/dist/cjs/tx/personal-kiosk.js.map +7 -0
  35. package/dist/cjs/tx/rules/attach.d.ts +7 -0
  36. package/dist/cjs/tx/rules/attach.js +62 -0
  37. package/dist/cjs/tx/rules/attach.js.map +7 -0
  38. package/dist/cjs/tx/rules/resolve.d.ts +15 -0
  39. package/dist/cjs/tx/rules/resolve.js +79 -0
  40. package/dist/cjs/tx/rules/resolve.js.map +7 -0
  41. package/dist/cjs/tx/transfer-policy.d.ts +29 -0
  42. package/dist/cjs/tx/transfer-policy.js +78 -0
  43. package/dist/cjs/tx/transfer-policy.js.map +7 -0
  44. package/dist/cjs/types/index.d.ts +17 -0
  45. package/dist/cjs/types/index.js +20 -0
  46. package/dist/cjs/types/index.js.map +7 -0
  47. package/dist/cjs/types/kiosk.d.ts +159 -0
  48. package/dist/cjs/types/kiosk.js +37 -0
  49. package/dist/cjs/types/kiosk.js.map +7 -0
  50. package/dist/cjs/types/transfer-policy.d.ts +51 -0
  51. package/dist/cjs/types/transfer-policy.js +35 -0
  52. package/dist/cjs/types/transfer-policy.js.map +7 -0
  53. package/dist/cjs/utils.d.ts +51 -0
  54. package/dist/cjs/utils.js +201 -0
  55. package/dist/cjs/utils.js.map +7 -0
  56. package/dist/esm/bcs.d.ts +38 -0
  57. package/dist/esm/bcs.js +34 -0
  58. package/dist/esm/bcs.js.map +7 -0
  59. package/dist/esm/client/kiosk-client.d.ts +76 -0
  60. package/dist/esm/client/kiosk-client.js +110 -0
  61. package/dist/esm/client/kiosk-client.js.map +7 -0
  62. package/dist/esm/client/kiosk-transaction.d.ts +185 -0
  63. package/dist/esm/client/kiosk-transaction.js +443 -0
  64. package/dist/esm/client/kiosk-transaction.js.map +7 -0
  65. package/dist/esm/client/tp-transaction.d.ts +114 -0
  66. package/dist/esm/client/tp-transaction.js +303 -0
  67. package/dist/esm/client/tp-transaction.js.map +7 -0
  68. package/dist/esm/constants.d.ts +24 -0
  69. package/dist/esm/constants.js +51 -0
  70. package/dist/esm/constants.js.map +7 -0
  71. package/dist/esm/index.d.ts +6 -0
  72. package/dist/esm/index.js +7 -0
  73. package/dist/esm/index.js.map +7 -0
  74. package/dist/esm/package.json +5 -0
  75. package/dist/esm/query/kiosk.d.ts +14 -0
  76. package/dist/esm/query/kiosk.js +117 -0
  77. package/dist/esm/query/kiosk.js.map +7 -0
  78. package/dist/esm/query/transfer-policy.d.ts +29 -0
  79. package/dist/esm/query/transfer-policy.js +78 -0
  80. package/dist/esm/query/transfer-policy.js.map +7 -0
  81. package/dist/esm/tx/kiosk.d.ts +71 -0
  82. package/dist/esm/tx/kiosk.js +110 -0
  83. package/dist/esm/tx/kiosk.js.map +7 -0
  84. package/dist/esm/tx/personal-kiosk.d.ts +7 -0
  85. package/dist/esm/tx/personal-kiosk.js +18 -0
  86. package/dist/esm/tx/personal-kiosk.js.map +7 -0
  87. package/dist/esm/tx/rules/attach.d.ts +7 -0
  88. package/dist/esm/tx/rules/attach.js +42 -0
  89. package/dist/esm/tx/rules/attach.js.map +7 -0
  90. package/dist/esm/tx/rules/resolve.d.ts +15 -0
  91. package/dist/esm/tx/rules/resolve.js +59 -0
  92. package/dist/esm/tx/rules/resolve.js.map +7 -0
  93. package/dist/esm/tx/transfer-policy.d.ts +29 -0
  94. package/dist/esm/tx/transfer-policy.js +58 -0
  95. package/dist/esm/tx/transfer-policy.js.map +7 -0
  96. package/dist/esm/types/index.d.ts +17 -0
  97. package/dist/esm/types/index.js +3 -0
  98. package/dist/esm/types/index.js.map +7 -0
  99. package/dist/esm/types/kiosk.d.ts +159 -0
  100. package/dist/esm/types/kiosk.js +17 -0
  101. package/dist/esm/types/kiosk.js.map +7 -0
  102. package/dist/esm/types/transfer-policy.d.ts +51 -0
  103. package/dist/esm/types/transfer-policy.js +15 -0
  104. package/dist/esm/types/transfer-policy.js.map +7 -0
  105. package/dist/esm/utils.d.ts +51 -0
  106. package/dist/esm/utils.js +186 -0
  107. package/dist/esm/utils.js.map +7 -0
  108. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  109. package/dist/tsconfig.tsbuildinfo +1 -0
  110. package/package.json +53 -0
  111. package/src/bcs.ts +39 -0
  112. package/src/client/kiosk-client.ts +169 -0
  113. package/src/client/kiosk-transaction.ts +538 -0
  114. package/src/client/tp-transaction.ts +363 -0
  115. package/src/constants.ts +85 -0
  116. package/src/index.ts +10 -0
  117. package/src/query/kiosk.ts +193 -0
  118. package/src/query/transfer-policy.ts +137 -0
  119. package/src/tx/kiosk.ts +244 -0
  120. package/src/tx/personal-kiosk.ts +35 -0
  121. package/src/tx/rules/attach.ts +74 -0
  122. package/src/tx/rules/resolve.ts +87 -0
  123. package/src/tx/transfer-policy.ts +121 -0
  124. package/src/types/index.ts +25 -0
  125. package/src/types/kiosk.ts +178 -0
  126. package/src/types/transfer-policy.ts +70 -0
  127. package/src/utils.ts +289 -0
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var kiosk_client_exports = {};
20
+ __export(kiosk_client_exports, {
21
+ KioskClient: () => KioskClient
22
+ });
23
+ module.exports = __toCommonJS(kiosk_client_exports);
24
+ var import_client = require("@iota/iota-sdk/client");
25
+ var import_constants = require("../constants.js");
26
+ var import_kiosk = require("../query/kiosk.js");
27
+ var import_transfer_policy = require("../query/transfer-policy.js");
28
+ class KioskClient {
29
+ constructor(options) {
30
+ this.client = options.client;
31
+ this.network = options.network;
32
+ this.rules = import_constants.rules;
33
+ this.packageIds = options.packageIds;
34
+ if (options.packageIds) this.rules.push(...(0, import_constants.getBaseRules)(options.packageIds));
35
+ }
36
+ /// Querying
37
+ /**
38
+ * Get an addresses's owned kiosks.
39
+ * @param address The address for which we want to retrieve the kiosks.
40
+ * @param pagination Optional pagination arguments.
41
+ * @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.
42
+ */
43
+ async getOwnedKiosks({
44
+ address,
45
+ pagination
46
+ }) {
47
+ const personalPackageId = this.packageIds?.personalKioskRulePackageId || (0, import_client.getNetwork)(this.network).kiosk?.personalKioskRulePackageId || "";
48
+ return (0, import_kiosk.getOwnedKiosks)(this.client, address, {
49
+ pagination,
50
+ personalKioskType: personalPackageId ? `${personalPackageId}::personal_kiosk::PersonalKioskCap` : ""
51
+ });
52
+ }
53
+ /**
54
+ * Fetches the kiosk contents.
55
+ * @param id The ID of the kiosk to fetch.
56
+ * @param options Optional to control the fetch behavior.
57
+ * @returns
58
+ */
59
+ async getKiosk({
60
+ id,
61
+ options
62
+ }) {
63
+ return (await (0, import_kiosk.fetchKiosk)(
64
+ this.client,
65
+ id,
66
+ {
67
+ limit: 1e3
68
+ },
69
+ options || {}
70
+ )).data;
71
+ }
72
+ /**
73
+ * Fetch the extension data (if any) for a kiosk, by type
74
+ * @param kioskId The ID of the kiosk to lookup
75
+ * @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)
76
+ */
77
+ async getKioskExtension({ kioskId, type }) {
78
+ return (0, import_kiosk.fetchKioskExtension)(this.client, kioskId, type);
79
+ }
80
+ /**
81
+ * Query the Transfer Policy(ies) for type `T`.
82
+ * @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)
83
+ */
84
+ async getTransferPolicies({ type }) {
85
+ return (0, import_transfer_policy.queryTransferPolicy)(this.client, type);
86
+ }
87
+ /**
88
+ * Query all the owned transfer policies for an address.
89
+ * Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.
90
+ * @param address The address we're searching the owned transfer policies for.
91
+ */
92
+ async getOwnedTransferPolicies({ address }) {
93
+ return (0, import_transfer_policy.queryOwnedTransferPolicies)(this.client, address);
94
+ }
95
+ /**
96
+ * Query the Transfer Policy Cap for type `T`, owned by `address`
97
+ * @param type The Type `T` for the object
98
+ * @param address The address that owns the cap.
99
+ */
100
+ async getOwnedTransferPoliciesByType({ type, address }) {
101
+ return (0, import_transfer_policy.queryTransferPolicyCapsByType)(this.client, address, type);
102
+ }
103
+ // Someone would just have to create a `kiosk-client.ts` file in their project, initialize a KioskClient
104
+ // and call the `addRuleResolver` function. Each rule has a `resolve` function.
105
+ // The resolve function is automatically called on `purchaseAndResolve` function call.
106
+ addRuleResolver(rule) {
107
+ if (this.rules.find((x) => x.rule === rule.rule))
108
+ throw new Error(`Rule ${rule.rule} resolver already exists.`);
109
+ this.rules.push(rule);
110
+ }
111
+ /**
112
+ * A convenient helper to get the packageIds for our supported ruleset,
113
+ * based on `kioskClient` configuration.
114
+ */
115
+ getRulePackageId(rule) {
116
+ const rules2 = this.packageIds || {};
117
+ const network = this.network;
118
+ const networkKiosk = (0, import_client.getNetwork)(network).kiosk;
119
+ const rulePackageId = rules2[rule] || networkKiosk?.[rule];
120
+ if (!rulePackageId) {
121
+ throw new Error(`Missing packageId for rule ${rule}`);
122
+ }
123
+ return rulePackageId;
124
+ }
125
+ }
126
+ //# sourceMappingURL=kiosk-client.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/client/kiosk-client.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { NetworkId } from '@iota/iota-sdk/client';\nimport { getNetwork } from '@iota/iota-sdk/client';\nimport type { PaginationArguments, IotaClient } from '@iota/iota-sdk/client';\n\nimport { getBaseRules, rules } from '../constants.js';\nimport type { BaseRulePackageIds, TransferPolicyRule } from '../constants.js';\nimport { fetchKiosk, fetchKioskExtension, getOwnedKiosks } from '../query/kiosk.js';\nimport {\n queryOwnedTransferPolicies,\n queryTransferPolicy,\n queryTransferPolicyCapsByType,\n} from '../query/transfer-policy.js';\nimport type {\n FetchKioskOptions,\n KioskClientOptions,\n KioskData,\n OwnedKiosks,\n} from '../types/index.js';\n\n/**\n * A Client that allows you to interact with kiosk.\n * Offers utilities to query kiosk, craft transactions to edit your own kiosk,\n * purchase, manage transfer policies, create new kiosks etc.\n * If you pass packageIds, all functionality will be managed using these packages.\n */\nexport class KioskClient {\n client: IotaClient;\n network: NetworkId;\n rules: TransferPolicyRule[];\n packageIds?: BaseRulePackageIds;\n\n constructor(options: KioskClientOptions) {\n this.client = options.client;\n this.network = options.network;\n this.rules = rules; // add all the default rules.\n this.packageIds = options.packageIds;\n\n // Add the custom Package Ids too on the rule list.\n // Only adds the rules that are passed in the packageId object.\n if (options.packageIds) this.rules.push(...getBaseRules(options.packageIds));\n }\n\n /// Querying\n\n /**\n * Get an addresses's owned kiosks.\n * @param address The address for which we want to retrieve the kiosks.\n * @param pagination Optional pagination arguments.\n * @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.\n */\n async getOwnedKiosks({\n address,\n pagination,\n }: {\n address: string;\n pagination?: PaginationArguments<string>;\n }): Promise<OwnedKiosks> {\n const personalPackageId =\n this.packageIds?.personalKioskRulePackageId ||\n getNetwork(this.network).kiosk?.personalKioskRulePackageId ||\n '';\n\n return getOwnedKiosks(this.client, address, {\n pagination,\n personalKioskType: personalPackageId\n ? `${personalPackageId}::personal_kiosk::PersonalKioskCap`\n : '',\n });\n }\n\n /**\n * Fetches the kiosk contents.\n * @param id The ID of the kiosk to fetch.\n * @param options Optional to control the fetch behavior.\n * @returns\n */\n async getKiosk({\n id,\n options,\n }: {\n id: string;\n options?: FetchKioskOptions;\n }): Promise<KioskData> {\n return (\n await fetchKiosk(\n this.client,\n id,\n {\n limit: 1000,\n },\n options || {},\n )\n ).data;\n }\n\n /**\n * Fetch the extension data (if any) for a kiosk, by type\n * @param kioskId The ID of the kiosk to lookup\n * @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)\n */\n async getKioskExtension({ kioskId, type }: { kioskId: string; type: string }) {\n return fetchKioskExtension(this.client, kioskId, type);\n }\n\n /**\n * Query the Transfer Policy(ies) for type `T`.\n * @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)\n */\n async getTransferPolicies({ type }: { type: string }) {\n return queryTransferPolicy(this.client, type);\n }\n\n /**\n * Query all the owned transfer policies for an address.\n * Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.\n * @param address The address we're searching the owned transfer policies for.\n */\n async getOwnedTransferPolicies({ address }: { address: string }) {\n return queryOwnedTransferPolicies(this.client, address);\n }\n\n /**\n * Query the Transfer Policy Cap for type `T`, owned by `address`\n * @param type The Type `T` for the object\n * @param address The address that owns the cap.\n */\n async getOwnedTransferPoliciesByType({ type, address }: { type: string; address: string }) {\n return queryTransferPolicyCapsByType(this.client, address, type);\n }\n\n // Someone would just have to create a `kiosk-client.ts` file in their project, initialize a KioskClient\n // and call the `addRuleResolver` function. Each rule has a `resolve` function.\n // The resolve function is automatically called on `purchaseAndResolve` function call.\n addRuleResolver(rule: TransferPolicyRule) {\n if (this.rules.find((x) => x.rule === rule.rule))\n throw new Error(`Rule ${rule.rule} resolver already exists.`);\n this.rules.push(rule);\n }\n\n /**\n * A convenient helper to get the packageIds for our supported ruleset,\n * based on `kioskClient` configuration.\n */\n getRulePackageId(\n rule:\n | 'kioskLockRulePackageId'\n | 'royaltyRulePackageId'\n | 'personalKioskRulePackageId'\n | 'floorPriceRulePackageId',\n ) {\n const rules = this.packageIds || {};\n const network = this.network;\n\n const networkKiosk = getNetwork(network).kiosk;\n\n const rulePackageId = rules[rule] || networkKiosk?.[rule];\n\n /// Check existence of rule throw an error if it's not found.\n if (!rulePackageId) {\n throw new Error(`Missing packageId for rule ${rule}`);\n }\n\n return rulePackageId;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,oBAA2B;AAG3B,uBAAoC;AAEpC,mBAAgE;AAChE,6BAIO;AAcA,MAAM,YAAY;AAAA,EAMrB,YAAY,SAA6B;AACrC,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ;AACvB,SAAK,QAAQ;AACb,SAAK,aAAa,QAAQ;AAI1B,QAAI,QAAQ,WAAY,MAAK,MAAM,KAAK,OAAG,+BAAa,QAAQ,UAAU,CAAC;AAAA,EAC/E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,eAAe;AAAA,IACjB;AAAA,IACA;AAAA,EACJ,GAGyB;AACrB,UAAM,oBACF,KAAK,YAAY,kCACjB,0BAAW,KAAK,OAAO,EAAE,OAAO,8BAChC;AAEJ,eAAO,6BAAe,KAAK,QAAQ,SAAS;AAAA,MACxC;AAAA,MACA,mBAAmB,oBACb,GAAG,iBAAiB,uCACpB;AAAA,IACV,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,SAAS;AAAA,IACX;AAAA,IACA;AAAA,EACJ,GAGuB;AACnB,YACI,UAAM;AAAA,MACF,KAAK;AAAA,MACL;AAAA,MACA;AAAA,QACI,OAAO;AAAA,MACX;AAAA,MACA,WAAW,CAAC;AAAA,IAChB,GACF;AAAA,EACN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,kBAAkB,EAAE,SAAS,KAAK,GAAsC;AAC1E,eAAO,kCAAoB,KAAK,QAAQ,SAAS,IAAI;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,oBAAoB,EAAE,KAAK,GAAqB;AAClD,eAAO,4CAAoB,KAAK,QAAQ,IAAI;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,yBAAyB,EAAE,QAAQ,GAAwB;AAC7D,eAAO,mDAA2B,KAAK,QAAQ,OAAO;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,+BAA+B,EAAE,MAAM,QAAQ,GAAsC;AACvF,eAAO,sDAA8B,KAAK,QAAQ,SAAS,IAAI;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAgB,MAA0B;AACtC,QAAI,KAAK,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI;AAC3C,YAAM,IAAI,MAAM,QAAQ,KAAK,IAAI,2BAA2B;AAChE,SAAK,MAAM,KAAK,IAAI;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,iBACI,MAKF;AACE,UAAMA,SAAQ,KAAK,cAAc,CAAC;AAClC,UAAM,UAAU,KAAK;AAErB,UAAM,mBAAe,0BAAW,OAAO,EAAE;AAEzC,UAAM,gBAAgBA,OAAM,IAAI,KAAK,eAAe,IAAI;AAGxD,QAAI,CAAC,eAAe;AAChB,YAAM,IAAI,MAAM,8BAA8B,IAAI,EAAE;AAAA,IACxD;AAEA,WAAO;AAAA,EACX;AACJ;",
6
+ "names": ["rules"]
7
+ }
@@ -0,0 +1,185 @@
1
+ import type { Transaction, TransactionArgument, TransactionObjectArgument } from '@iota/iota-sdk/transactions';
2
+ import type { ItemId, ItemReference, ItemValue, KioskOwnerCap, ObjectArgument, Price, PurchaseOptions } from '../types/index.js';
3
+ import type { KioskClient } from './kiosk-client.js';
4
+ export type KioskTransactionParams = {
5
+ /** The Transaction for this run */
6
+ transaction: Transaction;
7
+ /** @deprecated use transaction instead */
8
+ transactionBlock?: Transaction;
9
+ /**
10
+ * You can create a new KioskClient by calling `new KioskClient()`
11
+ */
12
+ kioskClient: KioskClient;
13
+ /**
14
+ * You can optionally pass in the `cap` as returned
15
+ * from `kioskClient.getOwnedKiosks` when initializing the client
16
+ * Otherwise, you can set it by calling `kioskTransaction.setCap()`
17
+ */
18
+ cap?: KioskOwnerCap;
19
+ };
20
+ /**
21
+ * A helper for building transactions that involve kiosk.
22
+ */
23
+ export declare class KioskTransaction {
24
+ #private;
25
+ transaction: Transaction;
26
+ kioskClient: KioskClient;
27
+ kiosk?: TransactionObjectArgument;
28
+ kioskCap?: TransactionObjectArgument;
29
+ constructor({ transactionBlock, transaction, kioskClient, cap, }: KioskTransactionParams);
30
+ /**
31
+ * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
32
+ * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.
33
+ * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
34
+ */
35
+ create(): this;
36
+ /**
37
+ * Creates a personal kiosk & shares it.
38
+ * The `PersonalKioskCap` is transferred to the signer.
39
+ * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
40
+ */
41
+ createPersonal(borrow?: boolean): this;
42
+ /**
43
+ * Converts a kiosk to a Personal (Soulbound) Kiosk.
44
+ * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.
45
+ */
46
+ convertToPersonal(borrow?: boolean): this;
47
+ /**
48
+ * Single function way to create a kiosk, share it and transfer the cap to the specified address.
49
+ */
50
+ createAndShare(address: string): void;
51
+ /**
52
+ * Shares the kiosk.
53
+ */
54
+ share(): void;
55
+ /**
56
+ * Should be called only after `create` is called.
57
+ * It shares the kiosk & transfers the cap to the specified address.
58
+ */
59
+ shareAndTransferCap(address: string): void;
60
+ /**
61
+ * A function to borrow an item from a kiosk & execute any function with it.
62
+ */
63
+ borrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void): void;
64
+ /**
65
+ * Borrows an item from the kiosk.
66
+ * This will fail if the item is listed for sale.
67
+ *
68
+ * Requires calling `return`.
69
+ */
70
+ borrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument];
71
+ /**
72
+ * Returns the item back to the kiosk.
73
+ * Accepts the parameters returned from the `borrow` function.
74
+ */
75
+ return({ itemType, item, promise }: ItemValue & {
76
+ promise: TransactionArgument;
77
+ }): this;
78
+ /**
79
+ * A function to withdraw from kiosk
80
+ * @param address Where to transfer the coin.
81
+ * @param amount The amount we aim to withdraw.
82
+ */
83
+ withdraw(address: string, amount?: string | bigint | number): this;
84
+ /**
85
+ * A function to place an item in the kiosk.
86
+ * @param itemType The type `T` of the item
87
+ * @param item The ID or Transaction Argument of the item
88
+ */
89
+ place({ itemType, item }: ItemReference): this;
90
+ /**
91
+ * A function to place an item in the kiosk and list it for sale in one transaction.
92
+ * @param itemType The type `T` of the item
93
+ * @param item The ID or Transaction Argument of the item
94
+ * @param price The price in NANOS
95
+ */
96
+ placeAndList({ itemType, item, price }: ItemReference & Price): this;
97
+ /**
98
+ * A function to list an item in the kiosk.
99
+ * @param itemType The type `T` of the item
100
+ * @param itemId The ID of the item
101
+ * @param price The price in NANOS
102
+ */
103
+ list({ itemType, itemId, price }: ItemId & {
104
+ price: string | bigint;
105
+ }): this;
106
+ /**
107
+ * A function to delist an item from the kiosk.
108
+ * @param itemType The type `T` of the item
109
+ * @param itemId The ID of the item
110
+ */
111
+ delist({ itemType, itemId }: ItemId): this;
112
+ /**
113
+ * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.
114
+
115
+ * @param itemType The type `T` of the item
116
+ * @param itemId The ID of the item
117
+ */
118
+ take({ itemType, itemId }: ItemId): TransactionObjectArgument;
119
+ /**
120
+ * Transfer a non-locked/non-listed item to an address.
121
+ *
122
+ * @param itemType The type `T` of the item
123
+ * @param itemId The ID of the item
124
+ * @param address The destination address
125
+ */
126
+ transfer({ itemType, itemId, address }: ItemId & {
127
+ address: string;
128
+ }): this;
129
+ /**
130
+ * A function to take lock an item in the kiosk.
131
+
132
+ * @param itemType The type `T` of the item
133
+ * @param item The ID or Transaction Argument of the item
134
+ * @param itemId The ID of the item - Deprecated: Use `item` instead.
135
+ * @param policy The Policy ID or Transaction Argument for item T
136
+ */
137
+ lock({ itemType, item, itemId, policy, }: ItemReference & {
138
+ policy: ObjectArgument;
139
+ itemId?: string;
140
+ }): this;
141
+ /**
142
+ * Purchase an item from a seller's kiosk.
143
+ * Returns [item, transferRequest]
144
+ * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`
145
+ * @param itemType The type `T` of the item
146
+ * @param itemId The ID of the item
147
+ * @param price The price in NANOS
148
+ * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
149
+ */
150
+ purchase({ itemType, itemId, price, sellerKiosk, }: ItemId & Price & {
151
+ sellerKiosk: ObjectArgument;
152
+ }): [
153
+ TransactionObjectArgument,
154
+ TransactionObjectArgument
155
+ ];
156
+ /**
157
+ * A function to purchase and resolve a transfer policy.
158
+ * If the transfer policy has the `lock` rule, the item is locked in the kiosk.
159
+ * Otherwise, the item is placed in the kiosk.
160
+ * @param itemType The type of the item
161
+ * @param itemId The id of the item
162
+ * @param price The price of the specified item
163
+ * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
164
+ * @param extraArgs Used to pass arguments for custom rule resolvers.
165
+ */
166
+ purchaseAndResolve({ itemType, itemId, price, sellerKiosk, extraArgs, }: ItemId & Price & {
167
+ sellerKiosk: ObjectArgument;
168
+ } & PurchaseOptions): Promise<this>;
169
+ /**
170
+ * A function to setup the client using an existing `ownerCap`,
171
+ * as return from the `kioskClient.getOwnedKiosks` function.
172
+ * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.
173
+ */
174
+ setCap(cap: KioskOwnerCap): this | undefined;
175
+ /**
176
+ * A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
177
+ * `PersonalKioskCap`, in case we are operating on a personal kiosk.
178
+ * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
179
+ */
180
+ finalize(): void;
181
+ setKioskCap(cap: TransactionObjectArgument): this;
182
+ setKiosk(kiosk: TransactionObjectArgument): this;
183
+ getKiosk(): TransactionObjectArgument;
184
+ getKioskCap(): TransactionObjectArgument;
185
+ }