@mysten/kiosk 0.14.5 → 1.0.0

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 (267) hide show
  1. package/CHANGELOG.md +112 -2
  2. package/dist/client/kiosk-client.d.mts +126 -0
  3. package/dist/client/kiosk-client.d.mts.map +1 -0
  4. package/dist/client/kiosk-client.mjs +124 -0
  5. package/dist/client/kiosk-client.mjs.map +1 -0
  6. package/dist/client/kiosk-transaction.d.mts +236 -0
  7. package/dist/client/kiosk-transaction.d.mts.map +1 -0
  8. package/dist/client/kiosk-transaction.mjs +472 -0
  9. package/dist/client/kiosk-transaction.mjs.map +1 -0
  10. package/dist/client/tp-transaction.d.mts +139 -0
  11. package/dist/client/tp-transaction.d.mts.map +1 -0
  12. package/dist/client/tp-transaction.mjs +273 -0
  13. package/dist/client/tp-transaction.mjs.map +1 -0
  14. package/dist/constants.d.mts +42 -0
  15. package/dist/constants.d.mts.map +1 -0
  16. package/dist/constants.mjs +62 -0
  17. package/dist/constants.mjs.map +1 -0
  18. package/dist/contracts/0x2/bag.mjs +19 -0
  19. package/dist/contracts/0x2/bag.mjs.map +1 -0
  20. package/dist/contracts/0x2/balance.mjs +20 -0
  21. package/dist/contracts/0x2/balance.mjs.map +1 -0
  22. package/dist/contracts/0x2/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +16 -0
  23. package/dist/contracts/0x2/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
  24. package/dist/contracts/0x2/kiosk.mjs +244 -0
  25. package/dist/contracts/0x2/kiosk.mjs.map +1 -0
  26. package/dist/contracts/0x2/kiosk_extension.mjs +25 -0
  27. package/dist/contracts/0x2/kiosk_extension.mjs.map +1 -0
  28. package/dist/contracts/0x2/transfer_policy.mjs +99 -0
  29. package/dist/contracts/0x2/transfer_policy.mjs.map +1 -0
  30. package/dist/contracts/0x2/vec_set.mjs +18 -0
  31. package/dist/contracts/0x2/vec_set.mjs.map +1 -0
  32. package/dist/contracts/kiosk/deps/sui/kiosk.mjs +98 -0
  33. package/dist/contracts/kiosk/deps/sui/kiosk.mjs.map +1 -0
  34. package/dist/contracts/kiosk/floor_price_rule.mjs +70 -0
  35. package/dist/contracts/kiosk/floor_price_rule.mjs.map +1 -0
  36. package/dist/contracts/kiosk/kiosk_lock_rule.mjs +72 -0
  37. package/dist/contracts/kiosk/kiosk_lock_rule.mjs.map +1 -0
  38. package/dist/contracts/kiosk/personal_kiosk.mjs +102 -0
  39. package/dist/contracts/kiosk/personal_kiosk.mjs.map +1 -0
  40. package/dist/contracts/kiosk/personal_kiosk_rule.mjs +66 -0
  41. package/dist/contracts/kiosk/personal_kiosk_rule.mjs.map +1 -0
  42. package/dist/contracts/kiosk/royalty_rule.mjs +115 -0
  43. package/dist/contracts/kiosk/royalty_rule.mjs.map +1 -0
  44. package/dist/contracts/utils/index.mjs +118 -0
  45. package/dist/contracts/utils/index.mjs.map +1 -0
  46. package/dist/index.d.mts +9 -0
  47. package/dist/index.mjs +9 -0
  48. package/dist/query/client-utils.mjs +30 -0
  49. package/dist/query/client-utils.mjs.map +1 -0
  50. package/dist/query/kiosk.mjs +154 -0
  51. package/dist/query/kiosk.mjs.map +1 -0
  52. package/dist/query/transfer-policy.mjs +110 -0
  53. package/dist/query/transfer-policy.mjs.map +1 -0
  54. package/dist/tx/kiosk.mjs +20 -0
  55. package/dist/tx/kiosk.mjs.map +1 -0
  56. package/dist/tx/rules/resolve.mjs +114 -0
  57. package/dist/tx/rules/resolve.mjs.map +1 -0
  58. package/dist/tx/transfer-policy.mjs +38 -0
  59. package/dist/tx/transfer-policy.mjs.map +1 -0
  60. package/dist/types/index.d.mts +23 -0
  61. package/dist/types/index.d.mts.map +1 -0
  62. package/dist/types/kiosk.d.mts +165 -0
  63. package/dist/types/kiosk.d.mts.map +1 -0
  64. package/dist/types/kiosk.mjs +21 -0
  65. package/dist/types/kiosk.mjs.map +1 -0
  66. package/dist/types/transfer-policy.d.mts +56 -0
  67. package/dist/types/transfer-policy.d.mts.map +1 -0
  68. package/dist/types/transfer-policy.mjs +19 -0
  69. package/dist/types/transfer-policy.mjs.map +1 -0
  70. package/dist/utils.d.mts +45 -0
  71. package/dist/utils.d.mts.map +1 -0
  72. package/dist/utils.mjs +156 -0
  73. package/dist/utils.mjs.map +1 -0
  74. package/package.json +31 -20
  75. package/src/client/kiosk-client.ts +42 -5
  76. package/src/client/kiosk-transaction.ts +144 -65
  77. package/src/client/tp-transaction.ts +149 -95
  78. package/src/constants.ts +19 -24
  79. package/src/contracts/0x2/accumulator.ts +24 -0
  80. package/src/contracts/0x2/accumulator_metadata.ts +38 -0
  81. package/src/contracts/0x2/accumulator_settlement.ts +14 -0
  82. package/src/contracts/0x2/address.ts +145 -0
  83. package/src/contracts/0x2/address_alias.ts +92 -0
  84. package/src/contracts/0x2/authenticator_state.ts +44 -0
  85. package/src/contracts/0x2/bag.ts +192 -0
  86. package/src/contracts/0x2/balance.ts +269 -0
  87. package/src/contracts/0x2/bcs.ts +495 -0
  88. package/src/contracts/0x2/bls12381.ts +717 -0
  89. package/src/contracts/0x2/borrow.ts +99 -0
  90. package/src/contracts/0x2/clock.ts +30 -0
  91. package/src/contracts/0x2/coin.ts +977 -0
  92. package/src/contracts/0x2/coin_registry.ts +874 -0
  93. package/src/contracts/0x2/config.ts +30 -0
  94. package/src/contracts/0x2/deny_list.ts +55 -0
  95. package/src/contracts/0x2/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.ts +12 -0
  96. package/src/contracts/0x2/derived_object.ts +95 -0
  97. package/src/contracts/0x2/display.ts +258 -0
  98. package/src/contracts/0x2/dynamic_field.ts +171 -0
  99. package/src/contracts/0x2/dynamic_object_field.ts +167 -0
  100. package/src/contracts/0x2/ecdsa_k1.ts +65 -0
  101. package/src/contracts/0x2/ecdsa_r1.ts +49 -0
  102. package/src/contracts/0x2/ecvrf.ts +29 -0
  103. package/src/contracts/0x2/ed25519.ts +25 -0
  104. package/src/contracts/0x2/event.ts +42 -0
  105. package/src/contracts/0x2/funds_accumulator.ts +86 -0
  106. package/src/contracts/0x2/groth16.ts +171 -0
  107. package/src/contracts/0x2/group_ops.ts +49 -0
  108. package/src/contracts/0x2/hash.ts +37 -0
  109. package/src/contracts/0x2/hex.ts +37 -0
  110. package/src/contracts/0x2/hmac.ts +21 -0
  111. package/src/contracts/0x2/kiosk.ts +797 -0
  112. package/src/contracts/0x2/kiosk_extension.ts +270 -0
  113. package/src/contracts/0x2/linked_table.ts +354 -0
  114. package/src/contracts/0x2/math.ts +117 -0
  115. package/src/contracts/0x2/nitro_attestation.ts +186 -0
  116. package/src/contracts/0x2/object.ts +249 -0
  117. package/src/contracts/0x2/object_bag.ts +210 -0
  118. package/src/contracts/0x2/object_table.ts +200 -0
  119. package/src/contracts/0x2/package.ts +414 -0
  120. package/src/contracts/0x2/party.ts +37 -0
  121. package/src/contracts/0x2/pay.ts +153 -0
  122. package/src/contracts/0x2/poseidon.ts +21 -0
  123. package/src/contracts/0x2/priority_queue.ts +139 -0
  124. package/src/contracts/0x2/random.ts +294 -0
  125. package/src/contracts/0x2/sui.ts +29 -0
  126. package/src/contracts/0x2/table.ts +200 -0
  127. package/src/contracts/0x2/table_vec.ts +232 -0
  128. package/src/contracts/0x2/token.ts +873 -0
  129. package/src/contracts/0x2/transfer.ts +216 -0
  130. package/src/contracts/0x2/transfer_policy.ts +400 -0
  131. package/src/contracts/0x2/tx_context.ts +129 -0
  132. package/src/contracts/0x2/types.ts +24 -0
  133. package/src/contracts/0x2/url.ts +77 -0
  134. package/src/contracts/0x2/vdf.ts +45 -0
  135. package/src/contracts/0x2/vec_map.ts +401 -0
  136. package/src/contracts/0x2/vec_set.ts +211 -0
  137. package/src/contracts/0x2/versioned.ts +153 -0
  138. package/src/contracts/0x2/zklogin_verified_id.ts +172 -0
  139. package/src/contracts/0x2/zklogin_verified_issuer.ts +99 -0
  140. package/src/contracts/kiosk/deps/sui/kiosk.ts +94 -0
  141. package/src/contracts/kiosk/deps/sui/object.ts +15 -0
  142. package/src/contracts/kiosk/floor_price_rule.ts +92 -0
  143. package/src/contracts/kiosk/kiosk_lock_rule.ts +97 -0
  144. package/src/contracts/kiosk/personal_kiosk.ts +295 -0
  145. package/src/contracts/kiosk/personal_kiosk_rule.ts +89 -0
  146. package/src/contracts/kiosk/royalty_rule.ts +144 -0
  147. package/src/contracts/kiosk/witness_rule.ts +92 -0
  148. package/src/contracts/utils/index.ts +234 -0
  149. package/src/query/client-utils.ts +51 -0
  150. package/src/query/kiosk.ts +128 -100
  151. package/src/query/transfer-policy.ts +112 -78
  152. package/src/tx/kiosk.ts +7 -231
  153. package/src/tx/rules/resolve.ts +97 -48
  154. package/src/tx/transfer-policy.ts +25 -86
  155. package/src/types/index.ts +3 -14
  156. package/src/types/kiosk.ts +10 -12
  157. package/src/types/transfer-policy.ts +4 -4
  158. package/src/utils.ts +90 -128
  159. package/dist/cjs/bcs.d.ts +0 -23
  160. package/dist/cjs/bcs.js +0 -50
  161. package/dist/cjs/bcs.js.map +0 -7
  162. package/dist/cjs/client/kiosk-client.d.ts +0 -76
  163. package/dist/cjs/client/kiosk-client.js +0 -123
  164. package/dist/cjs/client/kiosk-client.js.map +0 -7
  165. package/dist/cjs/client/kiosk-transaction.d.ts +0 -186
  166. package/dist/cjs/client/kiosk-transaction.js +0 -462
  167. package/dist/cjs/client/kiosk-transaction.js.map +0 -7
  168. package/dist/cjs/client/tp-transaction.d.ts +0 -114
  169. package/dist/cjs/client/tp-transaction.js +0 -307
  170. package/dist/cjs/client/tp-transaction.js.map +0 -7
  171. package/dist/cjs/constants.d.ts +0 -31
  172. package/dist/cjs/constants.js +0 -102
  173. package/dist/cjs/constants.js.map +0 -7
  174. package/dist/cjs/index.d.ts +0 -6
  175. package/dist/cjs/index.js +0 -24
  176. package/dist/cjs/index.js.map +0 -7
  177. package/dist/cjs/package.json +0 -5
  178. package/dist/cjs/query/kiosk.d.ts +0 -8
  179. package/dist/cjs/query/kiosk.js +0 -181
  180. package/dist/cjs/query/kiosk.js.map +0 -7
  181. package/dist/cjs/query/transfer-policy.d.ts +0 -29
  182. package/dist/cjs/query/transfer-policy.js +0 -92
  183. package/dist/cjs/query/transfer-policy.js.map +0 -7
  184. package/dist/cjs/tx/kiosk.d.ts +0 -71
  185. package/dist/cjs/tx/kiosk.js +0 -130
  186. package/dist/cjs/tx/kiosk.js.map +0 -7
  187. package/dist/cjs/tx/personal-kiosk.d.ts +0 -7
  188. package/dist/cjs/tx/personal-kiosk.js +0 -38
  189. package/dist/cjs/tx/personal-kiosk.js.map +0 -7
  190. package/dist/cjs/tx/rules/attach.d.ts +0 -7
  191. package/dist/cjs/tx/rules/attach.js +0 -62
  192. package/dist/cjs/tx/rules/attach.js.map +0 -7
  193. package/dist/cjs/tx/rules/resolve.d.ts +0 -15
  194. package/dist/cjs/tx/rules/resolve.js +0 -109
  195. package/dist/cjs/tx/rules/resolve.js.map +0 -7
  196. package/dist/cjs/tx/transfer-policy.d.ts +0 -29
  197. package/dist/cjs/tx/transfer-policy.js +0 -78
  198. package/dist/cjs/tx/transfer-policy.js.map +0 -7
  199. package/dist/cjs/types/index.d.ts +0 -27
  200. package/dist/cjs/types/index.js +0 -33
  201. package/dist/cjs/types/index.js.map +0 -7
  202. package/dist/cjs/types/kiosk.d.ts +0 -160
  203. package/dist/cjs/types/kiosk.js +0 -37
  204. package/dist/cjs/types/kiosk.js.map +0 -7
  205. package/dist/cjs/types/transfer-policy.d.ts +0 -53
  206. package/dist/cjs/types/transfer-policy.js +0 -35
  207. package/dist/cjs/types/transfer-policy.js.map +0 -7
  208. package/dist/cjs/utils.d.ts +0 -51
  209. package/dist/cjs/utils.js +0 -198
  210. package/dist/cjs/utils.js.map +0 -7
  211. package/dist/esm/bcs.d.ts +0 -23
  212. package/dist/esm/bcs.js +0 -35
  213. package/dist/esm/bcs.js.map +0 -7
  214. package/dist/esm/client/kiosk-client.d.ts +0 -76
  215. package/dist/esm/client/kiosk-client.js +0 -114
  216. package/dist/esm/client/kiosk-client.js.map +0 -7
  217. package/dist/esm/client/kiosk-transaction.d.ts +0 -186
  218. package/dist/esm/client/kiosk-transaction.js +0 -432
  219. package/dist/esm/client/kiosk-transaction.js.map +0 -7
  220. package/dist/esm/client/tp-transaction.d.ts +0 -114
  221. package/dist/esm/client/tp-transaction.js +0 -298
  222. package/dist/esm/client/tp-transaction.js.map +0 -7
  223. package/dist/esm/constants.d.ts +0 -31
  224. package/dist/esm/constants.js +0 -87
  225. package/dist/esm/constants.js.map +0 -7
  226. package/dist/esm/index.d.ts +0 -6
  227. package/dist/esm/index.js +0 -7
  228. package/dist/esm/index.js.map +0 -7
  229. package/dist/esm/package.json +0 -5
  230. package/dist/esm/query/kiosk.d.ts +0 -8
  231. package/dist/esm/query/kiosk.js +0 -169
  232. package/dist/esm/query/kiosk.js.map +0 -7
  233. package/dist/esm/query/transfer-policy.d.ts +0 -29
  234. package/dist/esm/query/transfer-policy.js +0 -76
  235. package/dist/esm/query/transfer-policy.js.map +0 -7
  236. package/dist/esm/tx/kiosk.d.ts +0 -71
  237. package/dist/esm/tx/kiosk.js +0 -110
  238. package/dist/esm/tx/kiosk.js.map +0 -7
  239. package/dist/esm/tx/personal-kiosk.d.ts +0 -7
  240. package/dist/esm/tx/personal-kiosk.js +0 -18
  241. package/dist/esm/tx/personal-kiosk.js.map +0 -7
  242. package/dist/esm/tx/rules/attach.d.ts +0 -7
  243. package/dist/esm/tx/rules/attach.js +0 -42
  244. package/dist/esm/tx/rules/attach.js.map +0 -7
  245. package/dist/esm/tx/rules/resolve.d.ts +0 -15
  246. package/dist/esm/tx/rules/resolve.js +0 -89
  247. package/dist/esm/tx/rules/resolve.js.map +0 -7
  248. package/dist/esm/tx/transfer-policy.d.ts +0 -29
  249. package/dist/esm/tx/transfer-policy.js +0 -58
  250. package/dist/esm/tx/transfer-policy.js.map +0 -7
  251. package/dist/esm/types/index.d.ts +0 -27
  252. package/dist/esm/types/index.js +0 -12
  253. package/dist/esm/types/index.js.map +0 -7
  254. package/dist/esm/types/kiosk.d.ts +0 -160
  255. package/dist/esm/types/kiosk.js +0 -17
  256. package/dist/esm/types/kiosk.js.map +0 -7
  257. package/dist/esm/types/transfer-policy.d.ts +0 -53
  258. package/dist/esm/types/transfer-policy.js +0 -15
  259. package/dist/esm/types/transfer-policy.js.map +0 -7
  260. package/dist/esm/utils.d.ts +0 -51
  261. package/dist/esm/utils.js +0 -183
  262. package/dist/esm/utils.js.map +0 -7
  263. package/dist/tsconfig.esm.tsbuildinfo +0 -1
  264. package/dist/tsconfig.tsbuildinfo +0 -1
  265. package/src/bcs.ts +0 -39
  266. package/src/tx/personal-kiosk.ts +0 -34
  267. package/src/tx/rules/attach.ts +0 -73
@@ -1,432 +0,0 @@
1
- var __typeError = (msg) => {
2
- throw TypeError(msg);
3
- };
4
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
- var _pendingShare, _pendingTransfer, _promise, _personalCap, _finalized, _KioskTransaction_instances, borrowFromPersonalCap_fn, setPendingStatuses_fn, validateKioskIsSet_fn, validateFinalizedStatus_fn;
10
- import * as kioskTx from "../tx/kiosk.js";
11
- import { convertToPersonalTx, transferPersonalCapTx } from "../tx/personal-kiosk.js";
12
- import { confirmRequest } from "../tx/transfer-policy.js";
13
- import { getNormalizedRuleType } from "../utils.js";
14
- class KioskTransaction {
15
- constructor({
16
- transactionBlock,
17
- transaction = transactionBlock,
18
- kioskClient,
19
- cap
20
- }) {
21
- __privateAdd(this, _KioskTransaction_instances);
22
- // If we're pending `share` of a new kiosk, `finalize()` will share it.
23
- __privateAdd(this, _pendingShare);
24
- // If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.
25
- __privateAdd(this, _pendingTransfer);
26
- // The promise that the personalCap will be returned on `finalize()`.
27
- __privateAdd(this, _promise);
28
- // The personal kiosk argument.
29
- __privateAdd(this, _personalCap);
30
- // A flag that checks whether kiosk TX is finalized.
31
- __privateAdd(this, _finalized, false);
32
- this.transaction = transaction;
33
- this.kioskClient = kioskClient;
34
- if (cap) this.setCap(cap);
35
- }
36
- /**
37
- * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
38
- * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.
39
- * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
40
- */
41
- create() {
42
- __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
43
- __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, {
44
- share: true,
45
- transfer: true
46
- });
47
- const [kiosk, cap] = kioskTx.createKiosk(this.transaction);
48
- this.kiosk = kiosk;
49
- this.kioskCap = cap;
50
- return this;
51
- }
52
- /**
53
- * Creates a personal kiosk & shares it.
54
- * The `PersonalKioskCap` is transferred to the signer.
55
- * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
56
- */
57
- createPersonal(borrow) {
58
- __privateSet(this, _pendingShare, true);
59
- return this.create().convertToPersonal(borrow);
60
- }
61
- /**
62
- * Converts a kiosk to a Personal (Soulbound) Kiosk.
63
- * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.
64
- */
65
- convertToPersonal(borrow) {
66
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
67
- const cap = convertToPersonalTx(
68
- this.transaction,
69
- this.kiosk,
70
- this.kioskCap,
71
- this.kioskClient.getRulePackageId("personalKioskRulePackageId")
72
- );
73
- if (borrow) __privateMethod(this, _KioskTransaction_instances, borrowFromPersonalCap_fn).call(this, cap);
74
- else __privateSet(this, _personalCap, cap);
75
- __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { transfer: true });
76
- return this;
77
- }
78
- /**
79
- * Single function way to create a kiosk, share it and transfer the cap to the specified address.
80
- */
81
- createAndShare(address) {
82
- __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
83
- const cap = kioskTx.createKioskAndShare(this.transaction);
84
- this.transaction.transferObjects([cap], this.transaction.pure.address(address));
85
- return this;
86
- }
87
- /**
88
- * Shares the kiosk.
89
- */
90
- share() {
91
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
92
- __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { share: false });
93
- kioskTx.shareKiosk(this.transaction, this.kiosk);
94
- return this;
95
- }
96
- /**
97
- * Should be called only after `create` is called.
98
- * It shares the kiosk & transfers the cap to the specified address.
99
- */
100
- shareAndTransferCap(address) {
101
- if (__privateGet(this, _personalCap))
102
- throw new Error("You can only call `shareAndTransferCap` on a non-personal kiosk.");
103
- __privateMethod(this, _KioskTransaction_instances, setPendingStatuses_fn).call(this, { transfer: false });
104
- this.share();
105
- this.transaction.transferObjects([this.kioskCap], this.transaction.pure.address(address));
106
- return this;
107
- }
108
- /**
109
- * A function to borrow an item from a kiosk & execute any function with it.
110
- * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.
111
- */
112
- borrowTx({ itemType, itemId }, callback) {
113
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
114
- const [itemObj, promise] = kioskTx.borrowValue(
115
- this.transaction,
116
- itemType,
117
- this.kiosk,
118
- this.kioskCap,
119
- itemId
120
- );
121
- callback(itemObj);
122
- return this.return({ itemType, item: itemObj, promise });
123
- }
124
- /**
125
- * Borrows an item from the kiosk.
126
- * This will fail if the item is listed for sale.
127
- *
128
- * Requires calling `return`.
129
- */
130
- borrow({ itemType, itemId }) {
131
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
132
- const [itemObj, promise] = kioskTx.borrowValue(
133
- this.transaction,
134
- itemType,
135
- this.kiosk,
136
- this.kioskCap,
137
- itemId
138
- );
139
- return [itemObj, promise];
140
- }
141
- /**
142
- * Returns the item back to the kiosk.
143
- * Accepts the parameters returned from the `borrow` function.
144
- */
145
- return({ itemType, item, promise }) {
146
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
147
- kioskTx.returnValue(this.transaction, itemType, this.kiosk, item, promise);
148
- return this;
149
- }
150
- /**
151
- * A function to withdraw from kiosk
152
- * @param address Where to trasnfer the coin.
153
- * @param amount The amount we aim to withdraw.
154
- */
155
- withdraw(address, amount) {
156
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
157
- const coin = kioskTx.withdrawFromKiosk(this.transaction, this.kiosk, this.kioskCap, amount);
158
- this.transaction.transferObjects([coin], this.transaction.pure.address(address));
159
- return this;
160
- }
161
- /**
162
- * A function to place an item in the kiosk.
163
- * @param itemType The type `T` of the item
164
- * @param item The ID or Transaction Argument of the item
165
- */
166
- place({ itemType, item }) {
167
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
168
- kioskTx.place(this.transaction, itemType, this.kiosk, this.kioskCap, item);
169
- return this;
170
- }
171
- /**
172
- * A function to place an item in the kiosk and list it for sale in one transaction.
173
- * @param itemType The type `T` of the item
174
- * @param item The ID or Transaction Argument of the item
175
- * @param price The price in MIST
176
- */
177
- placeAndList({ itemType, item, price }) {
178
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
179
- kioskTx.placeAndList(this.transaction, itemType, this.kiosk, this.kioskCap, item, price);
180
- return this;
181
- }
182
- /**
183
- * A function to list an item in the kiosk.
184
- * @param itemType The type `T` of the item
185
- * @param itemId The ID of the item
186
- * @param price The price in MIST
187
- */
188
- list({ itemType, itemId, price }) {
189
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
190
- kioskTx.list(this.transaction, itemType, this.kiosk, this.kioskCap, itemId, price);
191
- return this;
192
- }
193
- /**
194
- * A function to delist an item from the kiosk.
195
- * @param itemType The type `T` of the item
196
- * @param itemId The ID of the item
197
- */
198
- delist({ itemType, itemId }) {
199
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
200
- kioskTx.delist(this.transaction, itemType, this.kiosk, this.kioskCap, itemId);
201
- return this;
202
- }
203
- /**
204
- * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.
205
-
206
- * @param itemType The type `T` of the item
207
- * @param itemId The ID of the item
208
- */
209
- take({ itemType, itemId }) {
210
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
211
- return kioskTx.take(this.transaction, itemType, this.kiosk, this.kioskCap, itemId);
212
- }
213
- /**
214
- * Transfer a non-locked/non-listed item to an address.
215
- *
216
- * @param itemType The type `T` of the item
217
- * @param itemId The ID of the item
218
- * @param address The destination address
219
- */
220
- transfer({ itemType, itemId, address }) {
221
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
222
- const item = this.take({ itemType, itemId });
223
- this.transaction.transferObjects([item], this.transaction.pure.address(address));
224
- return this;
225
- }
226
- /**
227
- * A function to take lock an item in the kiosk.
228
-
229
- * @param itemType The type `T` of the item
230
- * @param item The ID or Transaction Argument of the item
231
- * @param itemId The ID of the item - Deprecated: Use `item` instead.
232
- * @param policy The Policy ID or Transaction Argument for item T
233
- */
234
- lock({
235
- itemType,
236
- item,
237
- itemId,
238
- policy
239
- }) {
240
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
241
- kioskTx.lock(this.transaction, itemType, this.kiosk, this.kioskCap, policy, itemId ?? item);
242
- return this;
243
- }
244
- /**
245
- * Purchase an item from a seller's kiosk.
246
- * Returns [item, transferRequest]
247
- * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`
248
- * @param itemType The type `T` of the item
249
- * @param itemId The ID of the item
250
- * @param price The price in MIST
251
- * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
252
- */
253
- purchase({
254
- itemType,
255
- itemId,
256
- price,
257
- sellerKiosk
258
- }) {
259
- const coin = this.transaction.splitCoins(this.transaction.gas, [
260
- this.transaction.pure.u64(price)
261
- ]);
262
- return kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);
263
- }
264
- /**
265
- * A function to purchase and resolve a transfer policy.
266
- * If the transfer policy has the `lock` rule, the item is locked in the kiosk.
267
- * Otherwise, the item is placed in the kiosk.
268
- * @param itemType The type of the item
269
- * @param itemId The id of the item
270
- * @param price The price of the specified item
271
- * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
272
- * @param extraArgs Used to pass arguments for custom rule resolvers.
273
- */
274
- async purchaseAndResolve({
275
- itemType,
276
- itemId,
277
- price,
278
- sellerKiosk,
279
- extraArgs
280
- }) {
281
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
282
- const policies = await this.kioskClient.getTransferPolicies({ type: itemType });
283
- if (policies.length === 0) {
284
- throw new Error(
285
- `The type ${itemType} doesn't have a Transfer Policy so it can't be traded through kiosk.`
286
- );
287
- }
288
- const policy = policies[0];
289
- const [purchasedItem, transferRequest] = this.purchase({
290
- itemType,
291
- itemId,
292
- price,
293
- sellerKiosk
294
- });
295
- let canTransferOutsideKiosk = true;
296
- for (const rule of policy.rules) {
297
- const ruleDefinition = this.kioskClient.rules.find(
298
- (x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule)
299
- );
300
- if (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);
301
- if (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;
302
- await ruleDefinition.resolveRuleFunction({
303
- packageId: ruleDefinition.packageId,
304
- transactionBlock: this.transaction,
305
- transaction: this.transaction,
306
- itemType,
307
- itemId,
308
- price: price.toString(),
309
- sellerKiosk,
310
- policyId: policy.id,
311
- transferRequest,
312
- purchasedItem,
313
- kiosk: this.kiosk,
314
- kioskCap: this.kioskCap,
315
- extraArgs: extraArgs || {},
316
- kioskClient: this.kioskClient
317
- });
318
- }
319
- confirmRequest(this.transaction, itemType, policy.id, transferRequest);
320
- if (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });
321
- return this;
322
- }
323
- /**
324
- * A function to setup the client using an existing `ownerCap`,
325
- * as return from the `kioskClient.getOwnedKiosks` function.
326
- * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.
327
- */
328
- setCap(cap) {
329
- __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
330
- this.kiosk = this.transaction.object(cap.kioskId);
331
- if (!cap.isPersonal) {
332
- this.kioskCap = this.transaction.object(cap.objectId);
333
- return;
334
- }
335
- return __privateMethod(this, _KioskTransaction_instances, borrowFromPersonalCap_fn).call(this, cap.objectId);
336
- }
337
- /**
338
- * A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
339
- * `PersonalKioskCap`, in case we are operating on a personal kiosk.
340
- * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
341
- */
342
- finalize() {
343
- __privateMethod(this, _KioskTransaction_instances, validateKioskIsSet_fn).call(this);
344
- if (__privateGet(this, _pendingShare)) this.share();
345
- if (!__privateGet(this, _personalCap)) {
346
- if (__privateGet(this, _pendingTransfer))
347
- throw new Error(
348
- "You need to transfer the `kioskOwnerCap` by calling `shareAndTransferCap()` before wrap"
349
- );
350
- return;
351
- }
352
- const packageId = this.kioskClient.getRulePackageId("personalKioskRulePackageId");
353
- if (__privateGet(this, _promise)) {
354
- this.transaction.moveCall({
355
- target: `${packageId}::personal_kiosk::return_val`,
356
- arguments: [__privateGet(this, _personalCap), this.transaction.object(this.kioskCap), __privateGet(this, _promise)]
357
- });
358
- }
359
- if (__privateGet(this, _pendingTransfer))
360
- transferPersonalCapTx(this.transaction, __privateGet(this, _personalCap), packageId);
361
- __privateSet(this, _finalized, true);
362
- }
363
- // Some setters in case we want custom behavior.
364
- setKioskCap(cap) {
365
- __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
366
- this.kioskCap = cap;
367
- return this;
368
- }
369
- setKiosk(kiosk) {
370
- __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
371
- this.kiosk = kiosk;
372
- return this;
373
- }
374
- // Some getters
375
- /*
376
- * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.
377
- */
378
- getKiosk() {
379
- __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
380
- if (!this.kiosk) throw new Error("Kiosk is not set.");
381
- return this.kiosk;
382
- }
383
- /*
384
- * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.
385
- */
386
- getKioskCap() {
387
- __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
388
- if (!this.kioskCap) throw new Error("Kiosk cap is not set");
389
- return this.kioskCap;
390
- }
391
- }
392
- _pendingShare = new WeakMap();
393
- _pendingTransfer = new WeakMap();
394
- _promise = new WeakMap();
395
- _personalCap = new WeakMap();
396
- _finalized = new WeakMap();
397
- _KioskTransaction_instances = new WeakSet();
398
- /**
399
- * A function to borrow from `personalCap`.
400
- */
401
- borrowFromPersonalCap_fn = function(personalCap) {
402
- const [kioskCap, promise] = this.transaction.moveCall({
403
- target: `${this.kioskClient.getRulePackageId(
404
- "personalKioskRulePackageId"
405
- )}::personal_kiosk::borrow_val`,
406
- arguments: [this.transaction.object(personalCap)]
407
- });
408
- this.kioskCap = kioskCap;
409
- __privateSet(this, _personalCap, this.transaction.object(personalCap));
410
- __privateSet(this, _promise, promise);
411
- return this;
412
- };
413
- setPendingStatuses_fn = function({ share, transfer }) {
414
- if (transfer !== void 0) __privateSet(this, _pendingTransfer, transfer);
415
- if (share !== void 0) __privateSet(this, _pendingShare, share);
416
- };
417
- validateKioskIsSet_fn = function() {
418
- __privateMethod(this, _KioskTransaction_instances, validateFinalizedStatus_fn).call(this);
419
- if (!this.kiosk || !this.kioskCap)
420
- throw new Error(
421
- "You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`"
422
- );
423
- };
424
- // Validates that `finalize`
425
- validateFinalizedStatus_fn = function() {
426
- if (__privateGet(this, _finalized))
427
- throw new Error("You can't add more transactions to a finalized kiosk transaction.");
428
- };
429
- export {
430
- KioskTransaction
431
- };
432
- //# sourceMappingURL=kiosk-transaction.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/client/kiosk-transaction.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tTransaction,\n\tTransactionArgument,\n\tTransactionObjectArgument,\n} from '@mysten/sui/transactions';\n\nimport * as kioskTx from '../tx/kiosk.js';\nimport { convertToPersonalTx, transferPersonalCapTx } from '../tx/personal-kiosk.js';\nimport { confirmRequest } from '../tx/transfer-policy.js';\nimport type {\n\tItemId,\n\tItemReference,\n\tItemValue,\n\tKioskOwnerCap,\n\tObjectArgument,\n\tPrice,\n\tPurchaseOptions,\n} from '../types/index.js';\nimport { getNormalizedRuleType } from '../utils.js';\nimport type { KioskClient } from './kiosk-client.js';\n\nexport type KioskTransactionParams = {\n\t/** The Transaction for this run */\n\ttransaction: Transaction;\n\n\t/** @deprecated use transaction instead */\n\ttransactionBlock?: Transaction;\n\t/**\n\t * You can create a new KioskClient by calling `new KioskClient()`\n\t */\n\tkioskClient: KioskClient;\n\t/**\n\t * You can optionally pass in the `cap` as returned\n\t * from `kioskClient.getOwnedKiosks` when initializing the client\n\t * Otherwise, you can set it by calling `kioskTransaction.setCap()`\n\t */\n\tcap?: KioskOwnerCap;\n};\n\n/**\n * A helper for building transactions that involve kiosk.\n */\nexport class KioskTransaction {\n\ttransaction: Transaction;\n\tkioskClient: KioskClient;\n\tkiosk?: TransactionObjectArgument;\n\tkioskCap?: TransactionObjectArgument;\n\t// If we're pending `share` of a new kiosk, `finalize()` will share it.\n\t#pendingShare?: boolean;\n\t// If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.\n\t#pendingTransfer?: boolean;\n\t// The promise that the personalCap will be returned on `finalize()`.\n\t#promise?: TransactionArgument | undefined;\n\t// The personal kiosk argument.\n\t#personalCap?: TransactionObjectArgument;\n\t// A flag that checks whether kiosk TX is finalized.\n\t#finalized: boolean = false;\n\n\tconstructor({\n\t\ttransactionBlock,\n\t\ttransaction = transactionBlock!,\n\t\tkioskClient,\n\t\tcap,\n\t}: KioskTransactionParams) {\n\t\tthis.transaction = transaction;\n\t\tthis.kioskClient = kioskClient;\n\n\t\tif (cap) this.setCap(cap);\n\t}\n\n\t/**\n\t * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.\n\t * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.\n\t * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n\t */\n\tcreate() {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.#setPendingStatuses({\n\t\t\tshare: true,\n\t\t\ttransfer: true,\n\t\t});\n\t\tconst [kiosk, cap] = kioskTx.createKiosk(this.transaction);\n\t\tthis.kiosk = kiosk;\n\t\tthis.kioskCap = cap;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a personal kiosk & shares it.\n\t * The `PersonalKioskCap` is transferred to the signer.\n\t * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n\t */\n\tcreatePersonal(borrow?: boolean) {\n\t\tthis.#pendingShare = true;\n\t\treturn this.create().convertToPersonal(borrow);\n\t}\n\n\t/**\n\t * Converts a kiosk to a Personal (Soulbound) Kiosk.\n\t * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.\n\t */\n\tconvertToPersonal(borrow?: boolean) {\n\t\tthis.#validateKioskIsSet();\n\n\t\tconst cap = convertToPersonalTx(\n\t\t\tthis.transaction,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\tthis.kioskClient.getRulePackageId('personalKioskRulePackageId'),\n\t\t);\n\n\t\t// if we enable `borrow`, we borrow the kioskCap from the cap.\n\t\tif (borrow) this.#borrowFromPersonalCap(cap);\n\t\telse this.#personalCap = cap;\n\n\t\tthis.#setPendingStatuses({ transfer: true });\n\t\treturn this;\n\t}\n\n\t/**\n\t * Single function way to create a kiosk, share it and transfer the cap to the specified address.\n\t */\n\tcreateAndShare(address: string) {\n\t\tthis.#validateFinalizedStatus();\n\t\tconst cap = kioskTx.createKioskAndShare(this.transaction);\n\t\tthis.transaction.transferObjects([cap], this.transaction.pure.address(address));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Shares the kiosk.\n\t */\n\tshare() {\n\t\tthis.#validateKioskIsSet();\n\t\tthis.#setPendingStatuses({ share: false });\n\t\tkioskTx.shareKiosk(this.transaction, this.kiosk!);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Should be called only after `create` is called.\n\t * It shares the kiosk & transfers the cap to the specified address.\n\t */\n\tshareAndTransferCap(address: string) {\n\t\tif (this.#personalCap)\n\t\t\tthrow new Error('You can only call `shareAndTransferCap` on a non-personal kiosk.');\n\t\tthis.#setPendingStatuses({ transfer: false });\n\t\tthis.share();\n\t\tthis.transaction.transferObjects([this.kioskCap!], this.transaction.pure.address(address));\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to borrow an item from a kiosk & execute any function with it.\n\t * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.\n\t */\n\tborrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [itemObj, promise] = kioskTx.borrowValue(\n\t\t\tthis.transaction,\n\t\t\titemType,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\titemId,\n\t\t);\n\n\t\tcallback(itemObj);\n\n\t\treturn this.return({ itemType, item: itemObj, promise });\n\t}\n\n\t/**\n\t * Borrows an item from the kiosk.\n\t * This will fail if the item is listed for sale.\n\t *\n\t * Requires calling `return`.\n\t */\n\tborrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument] {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [itemObj, promise] = kioskTx.borrowValue(\n\t\t\tthis.transaction,\n\t\t\titemType,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\titemId,\n\t\t);\n\n\t\treturn [itemObj, promise];\n\t}\n\n\t/**\n\t * Returns the item back to the kiosk.\n\t * Accepts the parameters returned from the `borrow` function.\n\t */\n\treturn({ itemType, item, promise }: ItemValue & { promise: TransactionArgument }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.returnValue(this.transaction, itemType, this.kiosk!, item, promise);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to withdraw from kiosk\n\t * @param address Where to trasnfer the coin.\n\t * @param amount The amount we aim to withdraw.\n\t */\n\twithdraw(address: string, amount?: string | bigint | number) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst coin = kioskTx.withdrawFromKiosk(this.transaction, this.kiosk!, this.kioskCap!, amount);\n\t\tthis.transaction.transferObjects([coin], this.transaction.pure.address(address));\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to place an item in the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t */\n\tplace({ itemType, item }: ItemReference) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.place(this.transaction, itemType, this.kiosk!, this.kioskCap!, item);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to place an item in the kiosk and list it for sale in one transaction.\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param price The price in MIST\n\t */\n\tplaceAndList({ itemType, item, price }: ItemReference & Price) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.placeAndList(this.transaction, itemType, this.kiosk!, this.kioskCap!, item, price);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to list an item in the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param price The price in MIST\n\t */\n\tlist({ itemType, itemId, price }: ItemId & { price: string | bigint }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.list(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId, price);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to delist an item from the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n\tdelist({ itemType, itemId }: ItemId) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.delist(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.\n\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n\ttake({ itemType, itemId }: ItemId): TransactionObjectArgument {\n\t\tthis.#validateKioskIsSet();\n\t\treturn kioskTx.take(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);\n\t}\n\n\t/**\n\t * Transfer a non-locked/non-listed item to an address.\n\t *\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param address The destination address\n\t */\n\ttransfer({ itemType, itemId, address }: ItemId & { address: string }) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst item = this.take({ itemType, itemId });\n\t\tthis.transaction.transferObjects([item], this.transaction.pure.address(address));\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to take lock an item in the kiosk.\n\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param itemId The ID of the item - Deprecated: Use `item` instead.\n\t * @param policy The Policy ID or Transaction Argument for item T\n\t */\n\tlock({\n\t\titemType,\n\t\titem,\n\t\titemId,\n\t\tpolicy,\n\t}: ItemReference & { policy: ObjectArgument; itemId?: string }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.lock(this.transaction, itemType, this.kiosk!, this.kioskCap!, policy, itemId ?? item);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Purchase an item from a seller's kiosk.\n\t * Returns [item, transferRequest]\n\t * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param price The price in MIST\n\t * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n\t */\n\tpurchase({\n\t\titemType,\n\t\titemId,\n\t\tprice,\n\t\tsellerKiosk,\n\t}: ItemId & Price & { sellerKiosk: ObjectArgument }): [\n\t\tTransactionObjectArgument,\n\t\tTransactionObjectArgument,\n\t] {\n\t\t// Split the coin for the amount of the listing.\n\t\tconst coin = this.transaction.splitCoins(this.transaction.gas, [\n\t\t\tthis.transaction.pure.u64(price),\n\t\t]);\n\t\treturn kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);\n\t}\n\n\t/**\n\t * A function to purchase and resolve a transfer policy.\n\t * If the transfer policy has the `lock` rule, the item is locked in the kiosk.\n\t * Otherwise, the item is placed in the kiosk.\n\t * @param itemType The type of the item\n\t * @param itemId The id of the item\n\t * @param price The price of the specified item\n\t * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n\t * @param extraArgs Used to pass arguments for custom rule resolvers.\n\t */\n\tasync purchaseAndResolve({\n\t\titemType,\n\t\titemId,\n\t\tprice,\n\t\tsellerKiosk,\n\t\textraArgs,\n\t}: ItemId & Price & { sellerKiosk: ObjectArgument } & PurchaseOptions) {\n\t\tthis.#validateKioskIsSet();\n\t\t// Get a list of the transfer policies.\n\t\tconst policies = await this.kioskClient.getTransferPolicies({ type: itemType });\n\n\t\tif (policies.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`The type ${itemType} doesn't have a Transfer Policy so it can't be traded through kiosk.`,\n\t\t\t);\n\t\t}\n\n\t\tconst policy = policies[0]; // we now pick the first one. We need to add an option to define which one.\n\n\t\t// initialize the purchase `kiosk::purchase`\n\t\tconst [purchasedItem, transferRequest] = this.purchase({\n\t\t\titemType,\n\t\t\titemId,\n\t\t\tprice,\n\t\t\tsellerKiosk,\n\t\t});\n\n\t\tlet canTransferOutsideKiosk = true;\n\n\t\tfor (const rule of policy.rules) {\n\t\t\tconst ruleDefinition = this.kioskClient.rules.find(\n\t\t\t\t(x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule),\n\t\t\t);\n\t\t\tif (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);\n\n\t\t\tif (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;\n\n\t\t\tawait ruleDefinition.resolveRuleFunction({\n\t\t\t\tpackageId: ruleDefinition.packageId,\n\t\t\t\ttransactionBlock: this.transaction,\n\t\t\t\ttransaction: this.transaction,\n\t\t\t\titemType,\n\t\t\t\titemId,\n\t\t\t\tprice: price.toString(),\n\t\t\t\tsellerKiosk,\n\t\t\t\tpolicyId: policy.id,\n\t\t\t\ttransferRequest,\n\t\t\t\tpurchasedItem,\n\t\t\t\tkiosk: this.kiosk!,\n\t\t\t\tkioskCap: this.kioskCap!,\n\t\t\t\textraArgs: extraArgs || {},\n\t\t\t\tkioskClient: this.kioskClient,\n\t\t\t});\n\t\t}\n\n\t\tconfirmRequest(this.transaction, itemType, policy.id, transferRequest);\n\n\t\tif (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to setup the client using an existing `ownerCap`,\n\t * as return from the `kioskClient.getOwnedKiosks` function.\n\t * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.\n\t */\n\tsetCap(cap: KioskOwnerCap) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kiosk = this.transaction.object(cap.kioskId);\n\t\tif (!cap.isPersonal) {\n\t\t\tthis.kioskCap = this.transaction.object(cap.objectId);\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.#borrowFromPersonalCap(cap.objectId);\n\t}\n\n\t/**\n\t *\tA function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the\n\t * `PersonalKioskCap`, in case we are operating on a personal kiosk.\n\t * \tIt will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.\n\t */\n\tfinalize() {\n\t\tthis.#validateKioskIsSet();\n\t\t// If we're pending the sharing of the new kiosk, share it.\n\t\tif (this.#pendingShare) this.share();\n\n\t\t// If we're operating on a non-personal kiosk, we don't need to do anything else.\n\t\tif (!this.#personalCap) {\n\t\t\t// If we're pending transfer though, we inform user to call `shareAndTransferCap()`.\n\t\t\tif (this.#pendingTransfer)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'You need to transfer the `kioskOwnerCap` by calling `shareAndTransferCap()` before wrap',\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\n\t\t// if we have a promise, return the `ownerCap` back to the personal cap.\n\t\tif (this.#promise) {\n\t\t\tthis.transaction.moveCall({\n\t\t\t\ttarget: `${packageId}::personal_kiosk::return_val`,\n\t\t\t\targuments: [this.#personalCap, this.transaction.object(this.kioskCap!), this.#promise!],\n\t\t\t});\n\t\t}\n\n\t\t// If we are pending transferring the personalCap, we do it here.\n\t\tif (this.#pendingTransfer)\n\t\t\ttransferPersonalCapTx(this.transaction, this.#personalCap, packageId);\n\n\t\t// Mark the transaction as finalized, so no other functions can be called.\n\t\tthis.#finalized = true;\n\t}\n\n\t// Some setters in case we want custom behavior.\n\tsetKioskCap(cap: TransactionObjectArgument) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kioskCap = cap;\n\t\treturn this;\n\t}\n\n\tsetKiosk(kiosk: TransactionObjectArgument) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kiosk = kiosk;\n\t\treturn this;\n\t}\n\n\t// Some getters\n\t/*\n\t * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.\n\t */\n\tgetKiosk() {\n\t\tthis.#validateFinalizedStatus();\n\t\tif (!this.kiosk) throw new Error('Kiosk is not set.');\n\t\treturn this.kiosk;\n\t}\n\n\t/*\n\t * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.\n\t */\n\tgetKioskCap() {\n\t\tthis.#validateFinalizedStatus();\n\t\tif (!this.kioskCap) throw new Error('Kiosk cap is not set');\n\t\treturn this.kioskCap;\n\t}\n\n\t/**\n\t * A function to borrow from `personalCap`.\n\t */\n\t#borrowFromPersonalCap(personalCap: ObjectArgument) {\n\t\tconst [kioskCap, promise] = this.transaction.moveCall({\n\t\t\ttarget: `${this.kioskClient.getRulePackageId(\n\t\t\t\t'personalKioskRulePackageId',\n\t\t\t)}::personal_kiosk::borrow_val`,\n\t\t\targuments: [this.transaction.object(personalCap)],\n\t\t});\n\n\t\tthis.kioskCap = kioskCap;\n\t\tthis.#personalCap = this.transaction.object(personalCap);\n\t\tthis.#promise = promise;\n\n\t\treturn this;\n\t}\n\n\t#setPendingStatuses({ share, transfer }: { share?: boolean; transfer?: boolean }) {\n\t\tif (transfer !== undefined) this.#pendingTransfer = transfer;\n\t\tif (share !== undefined) this.#pendingShare = share;\n\t}\n\n\t#validateKioskIsSet() {\n\t\tthis.#validateFinalizedStatus();\n\n\t\tif (!this.kiosk || !this.kioskCap)\n\t\t\tthrow new Error(\n\t\t\t\t'You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`',\n\t\t\t);\n\t}\n\n\t// Validates that `finalize`\n\t#validateFinalizedStatus() {\n\t\tif (this.#finalized)\n\t\t\tthrow new Error(\"You can't add more transactions to a finalized kiosk transaction.\");\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;AAAA;AASA,YAAY,aAAa;AACzB,SAAS,qBAAqB,6BAA6B;AAC3D,SAAS,sBAAsB;AAU/B,SAAS,6BAA6B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AAO;AACR;AAEA,wBAAmB,SAAC,EAAE,OAAO,SAAS,GAA4C;AACjF,MAAI,aAAa,OAAW,oBAAK,kBAAmB;AACpD,MAAI,UAAU,OAAW,oBAAK,eAAgB;AAC/C;AAEA,wBAAmB,WAAG;AACrB,wBAAK,yDAAL;AAEA,MAAI,CAAC,KAAK,SAAS,CAAC,KAAK;AACxB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AACF;AAAA;AAGA,6BAAwB,WAAG;AAC1B,MAAI,mBAAK;AACR,UAAM,IAAI,MAAM,mEAAmE;AACrF;",
6
- "names": []
7
- }
@@ -1,114 +0,0 @@
1
- import type { Transaction } from '@mysten/sui/transactions';
2
- import type { ObjectArgument, TransferPolicyCap } from '../types/index.js';
3
- import type { KioskClient } from './kiosk-client.js';
4
- export type TransferPolicyBaseParams = {
5
- type: string;
6
- publisher: ObjectArgument;
7
- skipCheck?: boolean;
8
- };
9
- export type TransferPolicyTransactionParams = {
10
- kioskClient: KioskClient;
11
- transaction: Transaction;
12
- /** @deprecated use transaction instead */
13
- transactionBlock?: Transaction;
14
- cap?: TransferPolicyCap;
15
- };
16
- export declare class TransferPolicyTransaction {
17
- #private;
18
- transaction: Transaction;
19
- kioskClient: KioskClient;
20
- policy?: ObjectArgument;
21
- policyCap?: ObjectArgument;
22
- type?: string;
23
- constructor({ kioskClient, transactionBlock, transaction, cap, }: TransferPolicyTransactionParams);
24
- /**
25
- * A function to create a new transfer policy.
26
- * Checks if there's already an existing transfer policy to prevent
27
- * double transfer polciy mistakes.
28
- * There's an optional `skipCheck` flag that will just create the policy
29
- * without checking
30
- *
31
- * @param type The Type (`T`) for which we're creating the transfer policy.
32
- * @param publisher The Publisher Object Id.
33
- * @param address Address to save the `TransferPolicyCap` object to.
34
- * @param skipCheck (Optional) skip checking if a transfer policy already exists
35
- */
36
- createAndShare({ type, publisher, address, skipCheck, }: TransferPolicyBaseParams & {
37
- address: string;
38
- }): Promise<void>;
39
- /**
40
- * A convenient function to create a Transfer Policy and attach some rules
41
- * before sharing it (so you can prepare it in a single PTB)
42
- * @param type The Type (`T`) for which we're creating the transfer policy.
43
- * @param publisher The Publisher Object Id.
44
- * @param address Address to save the `TransferPolicyCap` object to.
45
- * @param skipCheck (Optional) skip checking if a transfer policy already exists
46
- */
47
- create({ type, publisher, skipCheck, }: TransferPolicyBaseParams): Promise<TransferPolicyTransaction>;
48
- /**
49
- * This can be called after calling the `create` function to share the `TransferPolicy`,
50
- * and transfer the `TransferPolicyCap` to the specified address
51
- *
52
- * @param address The address to transfer the `TransferPolicyCap`
53
- */
54
- shareAndTransferCap(address: string): void;
55
- /**
56
- * Setup the TransferPolicy by passing a `cap` returned from `kioskClient.getOwnedTransferPolicies` or
57
- * `kioskClient.getOwnedTransferPoliciesByType`.
58
- * @param policyCapId The `TransferPolicyCap`
59
- */
60
- setCap({ policyId, policyCapId, type }: TransferPolicyCap): this;
61
- /**
62
- * Withdraw from the transfer policy's profits.
63
- * @param address Address to transfer the profits to.
64
- * @param amount (Optional) amount parameter. Will withdraw all profits if the amount is not specified.
65
- */
66
- withdraw(address: string, amount?: string | bigint): this;
67
- /**
68
- * Adds the Kiosk Royalty rule to the Transfer Policy.
69
- * You can pass the percentage, as well as a minimum amount.
70
- * The royalty that will be paid is the MAX(percentage, minAmount).
71
- * You can pass 0 in either value if you want only percentage royalty, or a fixed amount fee.
72
- * (but you should define at least one of them for the rule to make sense).
73
- *
74
- * @param percentageBps The royalty percentage in basis points. Use `percentageToBasisPoints` helper to convert from percentage [0,100].
75
- * @param minAmount The minimum royalty amount per request in MIST.
76
- */
77
- addRoyaltyRule(percentageBps: number | string, // this is in basis points.
78
- minAmount: number | string): this;
79
- /**
80
- * Adds the Kiosk Lock Rule to the Transfer Policy.
81
- * This Rule forces buyer to lock the item in the kiosk, preserving strong royalties.
82
- */
83
- addLockRule(): this;
84
- /**
85
- * Attaches the Personal Kiosk Rule, making a purchase valid only for `SoulBound` kiosks.
86
- */
87
- addPersonalKioskRule(): this;
88
- /**
89
- * A function to add the floor price rule to a transfer policy.
90
- * @param minPrice The minimum price in MIST.
91
- */
92
- addFloorPriceRule(minPrice: string | bigint): this;
93
- /**
94
- * Generic helper to remove a rule, not from the SDK's base ruleset.
95
- * @param ruleType The Rule Type
96
- * @param configType The Config Type
97
- */
98
- removeRule({ ruleType, configType }: {
99
- ruleType: string;
100
- configType: string;
101
- }): void;
102
- /**
103
- * Removes the lock rule.
104
- */
105
- removeLockRule(): this;
106
- /**
107
- * Removes the Royalty rule
108
- */
109
- removeRoyaltyRule(): this;
110
- removePersonalKioskRule(): this;
111
- removeFloorPriceRule(): this;
112
- getPolicy(): ObjectArgument;
113
- getPolicyCap(): ObjectArgument;
114
- }