@mysten/kiosk 0.14.6 → 1.0.1

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 +114 -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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,117 @@
1
1
  # @mysten/kiosk
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [339d1e0]
8
+ - @mysten/utils@0.3.0
9
+ - @mysten/bcs@2.0.1
10
+ - @mysten/sui@2.0.1
11
+
12
+ ## 1.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - e00788c: ### Breaking Changes
17
+
18
+ **Removed deprecated `transactionBlock` parameter**
19
+
20
+ The deprecated `transactionBlock` parameter has been removed from `KioskTransaction`,
21
+ `TransferPolicyTransaction`, and rule resolving functions. Use `transaction` instead:
22
+
23
+ ```diff
24
+ const kioskTx = new KioskTransaction({
25
+ - transactionBlock: tx,
26
+ + transaction: tx,
27
+ kioskClient,
28
+ cap,
29
+ });
30
+ ```
31
+
32
+ **Removed low-level transaction helper functions**
33
+
34
+ The following low-level helper functions have been removed. Use `KioskTransaction` and
35
+ `TransferPolicyTransaction` classes instead:
36
+
37
+ From kiosk operations:
38
+ - `createKiosk` - use `kioskTx.create()`
39
+ - `shareKiosk` - use `kioskTx.share()`
40
+ - `place` - use `kioskTx.place()`
41
+ - `lock` - use `kioskTx.lock()`
42
+ - `take` - use `kioskTx.take()`
43
+ - `list` - use `kioskTx.list()`
44
+ - `delist` - use `kioskTx.delist()`
45
+ - `placeAndList` - use `kioskTx.placeAndList()`
46
+ - `purchase` - use `kioskTx.purchase()`
47
+ - `withdrawFromKiosk` - use `kioskTx.withdraw()`
48
+ - `borrowValue` - use `kioskTx.borrow()`
49
+ - `returnValue` - use `kioskTx.return()`
50
+
51
+ From transfer policy operations:
52
+ - `createTransferPolicyWithoutSharing` - use `tpTx.create()`
53
+ - `shareTransferPolicy` - use `tpTx.shareAndTransferCap()`
54
+ - `confirmRequest` - handled automatically by `kioskTx.purchaseAndResolve()`
55
+ - `removeTransferPolicyRule` - use `tpTx.removeRule()`
56
+
57
+ From personal kiosk operations:
58
+ - `convertToPersonalTx` - use `kioskTx.convertToPersonal()`
59
+ - `transferPersonalCapTx` - handled automatically by `kioskTx.finalize()`
60
+
61
+ From rule attachment:
62
+ - `attachKioskLockRuleTx` - use `tpTx.addLockRule()`
63
+ - `attachRoyaltyRuleTx` - use `tpTx.addRoyaltyRule()`
64
+ - `attachPersonalKioskRuleTx` - use `tpTx.addPersonalKioskRule()`
65
+ - `attachFloorPriceRuleTx` - use `tpTx.addFloorPriceRule()`
66
+
67
+ **Updated client requirements**
68
+
69
+ The SDK now uses the core client API (`ClientWithCoreApi`) instead of direct JSON-RPC types.
70
+ Update your `KioskClient` initialization:
71
+
72
+ ```diff
73
+ const kioskClient = new KioskClient({
74
+ - client: new SuiClient({ url: getFullnodeUrl('mainnet') }),
75
+ + client: new SuiJsonRpcClient({
76
+ + url: getJsonRpcFullnodeUrl('mainnet'),
77
+ + network: 'mainnet',
78
+ + }),
79
+ network: Network.MAINNET,
80
+ });
81
+ ```
82
+
83
+ **Removed BCS exports**
84
+
85
+ The `KioskType` and other BCS type exports from `bcs.ts` have been removed. The SDK now uses
86
+ generated contract bindings internally.
87
+
88
+ ### Minor Changes
89
+
90
+ - e00788c: Update to use SuiJsonRpcClient instead of SuiClient
91
+
92
+ Updated all type signatures, internal usages, examples, and documentation to use
93
+ `SuiJsonRpcClient` from `@mysten/sui/jsonRpc` instead of the deprecated `SuiClient` from
94
+ `@mysten/sui/client`.
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [e00788c]
99
+ - Updated dependencies [e00788c]
100
+ - Updated dependencies [e00788c]
101
+ - Updated dependencies [e00788c]
102
+ - Updated dependencies [e00788c]
103
+ - Updated dependencies [e00788c]
104
+ - Updated dependencies [e00788c]
105
+ - Updated dependencies [e00788c]
106
+ - Updated dependencies [e00788c]
107
+ - Updated dependencies [e00788c]
108
+ - Updated dependencies [e00788c]
109
+ - Updated dependencies [e00788c]
110
+ - Updated dependencies [e00788c]
111
+ - Updated dependencies [e00788c]
112
+ - @mysten/sui@2.0.0
113
+ - @mysten/bcs@2.0.0
114
+
3
115
  ## 0.14.6
4
116
 
5
117
  ### Patch Changes
@@ -701,8 +813,8 @@
701
813
 
702
814
  - a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features
703
815
  and breaking changes. See the
704
- [full migration guide](https://sdk.mystenlabs.com/typescript/migrations/sui-1.0) for details on
705
- how to upgrade.
816
+ [full migration guide](https://sdk.mystenlabs.com/sui/migrations/sui-1.0) for details on how to
817
+ upgrade.
706
818
 
707
819
  ### Patch Changes
708
820
 
@@ -0,0 +1,126 @@
1
+ import { BaseRulePackageIds, TransferPolicyRule } from "../constants.mjs";
2
+ import { FetchKioskOptions, KioskData, KioskExtension, OwnedKiosks } from "../types/kiosk.mjs";
3
+ import { TransferPolicy, TransferPolicyCap } from "../types/transfer-policy.mjs";
4
+ import { KioskClientOptions } from "../types/index.mjs";
5
+ import { PaginationArguments } from "@mysten/sui/jsonRpc";
6
+ import { ClientWithCoreApi, SuiClientTypes } from "@mysten/sui/client";
7
+
8
+ //#region src/client/kiosk-client.d.ts
9
+ type KioskExtensionOptions<Name extends string = 'kiosk'> = {
10
+ name?: Name;
11
+ packageIds?: BaseRulePackageIds;
12
+ };
13
+ /**
14
+ * Creates a kiosk client extension that can be used with `client.$extend()`.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
19
+ * import { kiosk } from '@mysten/kiosk';
20
+ *
21
+ * const client = new SuiJsonRpcClient({
22
+ * url: getJsonRpcFullnodeUrl('mainnet'),
23
+ * network: 'mainnet',
24
+ * }).$extend(kiosk());
25
+ *
26
+ * const ownedKiosks = await client.kiosk.getOwnedKiosks({ address: '0x...' });
27
+ * ```
28
+ */
29
+ declare function kiosk<const Name extends string = 'kiosk'>({
30
+ name,
31
+ packageIds
32
+ }?: KioskExtensionOptions<Name>): {
33
+ name: Name;
34
+ register: (client: ClientWithCoreApi) => KioskClient;
35
+ };
36
+ /**
37
+ * A Client that allows you to interact with kiosk.
38
+ * Offers utilities to query kiosk, craft transactions to edit your own kiosk,
39
+ * purchase, manage transfer policies, create new kiosks etc.
40
+ * If you pass packageIds, all functionality will be managed using these packages.
41
+ */
42
+ declare class KioskClient {
43
+ client: ClientWithCoreApi;
44
+ network: SuiClientTypes.Network;
45
+ rules: TransferPolicyRule[];
46
+ packageIds?: BaseRulePackageIds;
47
+ constructor(options: KioskClientOptions);
48
+ /**
49
+ * Get an addresses's owned kiosks.
50
+ * @param address The address for which we want to retrieve the kiosks.
51
+ * @param pagination Optional pagination arguments.
52
+ * @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.
53
+ */
54
+ getOwnedKiosks({
55
+ address,
56
+ pagination
57
+ }: {
58
+ address: string;
59
+ pagination?: PaginationArguments<string>;
60
+ }): Promise<OwnedKiosks>;
61
+ /**
62
+ * Fetches the kiosk contents.
63
+ * @param id The ID of the kiosk to fetch.
64
+ * @param options Optional to control the fetch behavior.
65
+ * @returns
66
+ */
67
+ getKiosk({
68
+ id,
69
+ options
70
+ }: {
71
+ id: string;
72
+ options?: FetchKioskOptions;
73
+ }): Promise<KioskData>;
74
+ /**
75
+ * Fetch the extension data (if any) for a kiosk, by type
76
+ * @param kioskId The ID of the kiosk to lookup
77
+ * @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)
78
+ */
79
+ getKioskExtension({
80
+ kioskId,
81
+ type
82
+ }: {
83
+ kioskId: string;
84
+ type: string;
85
+ }): Promise<KioskExtension | null>;
86
+ /**
87
+ * Query the Transfer Policy(ies) for type `T`.
88
+ * @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)
89
+ */
90
+ getTransferPolicies({
91
+ type
92
+ }: {
93
+ type: string;
94
+ }): Promise<TransferPolicy[]>;
95
+ /**
96
+ * Query all the owned transfer policies for an address.
97
+ * Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.
98
+ * @param address The address we're searching the owned transfer policies for.
99
+ */
100
+ getOwnedTransferPolicies({
101
+ address
102
+ }: {
103
+ address: string;
104
+ }): Promise<TransferPolicyCap[] | undefined>;
105
+ /**
106
+ * Query the Transfer Policy Cap for type `T`, owned by `address`
107
+ * @param type The Type `T` for the object
108
+ * @param address The address that owns the cap.
109
+ */
110
+ getOwnedTransferPoliciesByType({
111
+ type,
112
+ address
113
+ }: {
114
+ type: string;
115
+ address: string;
116
+ }): Promise<TransferPolicyCap[]>;
117
+ addRuleResolver(rule: TransferPolicyRule): void;
118
+ /**
119
+ * A convenient helper to get the packageIds for our supported ruleset,
120
+ * based on `kioskClient` configuration.
121
+ */
122
+ getRulePackageId(rule: 'kioskLockRulePackageId' | 'royaltyRulePackageId' | 'personalKioskRulePackageId' | 'floorPriceRulePackageId'): string | undefined;
123
+ }
124
+ //#endregion
125
+ export { KioskClient, KioskExtensionOptions, kiosk };
126
+ //# sourceMappingURL=kiosk-client.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kiosk-client.d.mts","names":[],"sources":["../../src/client/kiosk-client.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA4BY;SACJ;eACM;;AAFd;AAqBA;;;;;;;;;AAsBA;;;;;;AA0BE,iBAhDc,KAgDd,CAAA,mBAAA,MAAA,GAAA,OAAA,CAAA,CAAA;EAAA,IAAA;EAAA;AAAA,CAAA,CAAA,EA7CC,qBA6CD,CA7CuB,IA6CvB,CAAA,CAAA,EAAA;EACA,IAAA,MAAA;EAGa,QAAA,EAAA,CAAA,MAAA,EA9CM,iBA8CN,EAAA,GA9CuB,WA8CvB;CACF;;;;;;;AA2Bc,cA1Dd,WAAA,CA0Dc;EAAS,MAAA,EAzD3B,iBAyD2B;EAAI,OAAA,EAxD9B,cAAA,CAAe,OAwDe;EAAqC,KAAA,EAvDrE,kBAuDqE,EAAA;EAQhD,UAAA,CAAA,EA9Df,kBA8De;EAAI,WAAA,CAAA,OAAA,EA5DX,kBA4DW;EAAoB;;;;;;EAkBA,cAAA,CAAA;IAAA,OAAA;IAAA;EAOZ,CAPY,EAAA;IAAqC,OAAA,EAAA,MAAA;IAOnE,UAAA,CAAA,EA7DR,mBA6DQ,CAAA,MAAA,CAAA;EAAkB,CAAA,CAAA,EA5DpC,OA4DoC,CA5D5B,WA4D4B,CAAA;;;;;;;;;;;;cA1CgB;MAAsB,QAAQ;;;;;;;;;;;;MASV,QAArC,cAAA;;;;;;;;;MAQa,QAApB,cAAA;;;;;;;;;;MAS+B,QAAvB,iBAAA;;;;;;;;;;;;MASiD,QAArC,iBAAA;wBAO9B"}
@@ -0,0 +1,124 @@
1
+ import { FLOOR_PRICE_RULE_ADDRESS, KIOSK_LOCK_RULE_ADDRESS, PERSONAL_KIOSK_RULE_ADDRESS, ROYALTY_RULE_ADDRESS, getBaseRules, rules } from "../constants.mjs";
2
+ import { fetchKiosk, fetchKioskExtension, getOwnedKiosks } from "../query/kiosk.mjs";
3
+ import { queryOwnedTransferPolicies, queryTransferPolicy, queryTransferPolicyCapsByType } from "../query/transfer-policy.mjs";
4
+
5
+ //#region src/client/kiosk-client.ts
6
+ /**
7
+ * Creates a kiosk client extension that can be used with `client.$extend()`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
12
+ * import { kiosk } from '@mysten/kiosk';
13
+ *
14
+ * const client = new SuiJsonRpcClient({
15
+ * url: getJsonRpcFullnodeUrl('mainnet'),
16
+ * network: 'mainnet',
17
+ * }).$extend(kiosk());
18
+ *
19
+ * const ownedKiosks = await client.kiosk.getOwnedKiosks({ address: '0x...' });
20
+ * ```
21
+ */
22
+ function kiosk({ name = "kiosk", packageIds } = {}) {
23
+ return {
24
+ name,
25
+ register: (client) => {
26
+ return new KioskClient({
27
+ client,
28
+ network: client.network,
29
+ packageIds
30
+ });
31
+ }
32
+ };
33
+ }
34
+ /**
35
+ * A Client that allows you to interact with kiosk.
36
+ * Offers utilities to query kiosk, craft transactions to edit your own kiosk,
37
+ * purchase, manage transfer policies, create new kiosks etc.
38
+ * If you pass packageIds, all functionality will be managed using these packages.
39
+ */
40
+ var KioskClient = class {
41
+ constructor(options) {
42
+ this.client = options.client;
43
+ this.network = options.network;
44
+ this.rules = rules;
45
+ this.packageIds = options.packageIds;
46
+ if (options.packageIds) this.rules.push(...getBaseRules(options.packageIds));
47
+ }
48
+ /**
49
+ * Get an addresses's owned kiosks.
50
+ * @param address The address for which we want to retrieve the kiosks.
51
+ * @param pagination Optional pagination arguments.
52
+ * @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.
53
+ */
54
+ async getOwnedKiosks({ address, pagination }) {
55
+ const personalPackageId = this.packageIds?.personalKioskRulePackageId || PERSONAL_KIOSK_RULE_ADDRESS[this.network];
56
+ return getOwnedKiosks(this.client, address, {
57
+ pagination,
58
+ personalKioskType: personalPackageId ? `${personalPackageId}::personal_kiosk::PersonalKioskCap` : ""
59
+ });
60
+ }
61
+ /**
62
+ * Fetches the kiosk contents.
63
+ * @param id The ID of the kiosk to fetch.
64
+ * @param options Optional to control the fetch behavior.
65
+ * @returns
66
+ */
67
+ async getKiosk({ id, options }) {
68
+ return (await fetchKiosk(this.client, id, {}, options || {})).data;
69
+ }
70
+ /**
71
+ * Fetch the extension data (if any) for a kiosk, by type
72
+ * @param kioskId The ID of the kiosk to lookup
73
+ * @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)
74
+ */
75
+ async getKioskExtension({ kioskId, type }) {
76
+ return fetchKioskExtension(this.client, kioskId, type);
77
+ }
78
+ /**
79
+ * Query the Transfer Policy(ies) for type `T`.
80
+ * @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)
81
+ */
82
+ async getTransferPolicies({ type }) {
83
+ return queryTransferPolicy(this.client, type);
84
+ }
85
+ /**
86
+ * Query all the owned transfer policies for an address.
87
+ * Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.
88
+ * @param address The address we're searching the owned transfer policies for.
89
+ */
90
+ async getOwnedTransferPolicies({ address }) {
91
+ return queryOwnedTransferPolicies(this.client, address);
92
+ }
93
+ /**
94
+ * Query the Transfer Policy Cap for type `T`, owned by `address`
95
+ * @param type The Type `T` for the object
96
+ * @param address The address that owns the cap.
97
+ */
98
+ async getOwnedTransferPoliciesByType({ type, address }) {
99
+ return queryTransferPolicyCapsByType(this.client, address, type);
100
+ }
101
+ addRuleResolver(rule) {
102
+ if (this.rules.find((x) => x.rule === rule.rule)) throw new Error(`Rule ${rule.rule} resolver already exists.`);
103
+ this.rules.push(rule);
104
+ }
105
+ /**
106
+ * A convenient helper to get the packageIds for our supported ruleset,
107
+ * based on `kioskClient` configuration.
108
+ */
109
+ getRulePackageId(rule) {
110
+ const rules$1 = this.packageIds || {};
111
+ const network = this.network;
112
+ if (!rules$1[rule] && network !== "mainnet" && network !== "testnet") throw new Error(`Missing packageId for rule ${rule}`);
113
+ switch (rule) {
114
+ case "kioskLockRulePackageId": return rules$1[rule] || KIOSK_LOCK_RULE_ADDRESS[network];
115
+ case "royaltyRulePackageId": return rules$1[rule] || ROYALTY_RULE_ADDRESS[network];
116
+ case "personalKioskRulePackageId": return rules$1[rule] || PERSONAL_KIOSK_RULE_ADDRESS[network];
117
+ case "floorPriceRulePackageId": return rules$1[rule] || FLOOR_PRICE_RULE_ADDRESS[network];
118
+ }
119
+ }
120
+ };
121
+
122
+ //#endregion
123
+ export { KioskClient, kiosk };
124
+ //# sourceMappingURL=kiosk-client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kiosk-client.mjs","names":["rules"],"sources":["../../src/client/kiosk-client.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PaginationArguments } from '@mysten/sui/jsonRpc';\nimport type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\n\nimport {\n\tFLOOR_PRICE_RULE_ADDRESS,\n\tgetBaseRules,\n\tKIOSK_LOCK_RULE_ADDRESS,\n\tPERSONAL_KIOSK_RULE_ADDRESS,\n\tROYALTY_RULE_ADDRESS,\n\trules,\n} from '../constants.js';\nimport type { BaseRulePackageIds, TransferPolicyRule } from '../constants.js';\nimport { fetchKiosk, fetchKioskExtension, getOwnedKiosks } from '../query/kiosk.js';\nimport {\n\tqueryOwnedTransferPolicies,\n\tqueryTransferPolicy,\n\tqueryTransferPolicyCapsByType,\n} from '../query/transfer-policy.js';\nimport type {\n\tFetchKioskOptions,\n\tKioskClientOptions,\n\tKioskData,\n\tOwnedKiosks,\n} from '../types/index.js';\n\nexport type KioskExtensionOptions<Name extends string = 'kiosk'> = {\n\tname?: Name;\n\tpackageIds?: BaseRulePackageIds;\n};\n\n/**\n * Creates a kiosk client extension that can be used with `client.$extend()`.\n *\n * @example\n * ```ts\n * import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';\n * import { kiosk } from '@mysten/kiosk';\n *\n * const client = new SuiJsonRpcClient({\n * url: getJsonRpcFullnodeUrl('mainnet'),\n * network: 'mainnet',\n * }).$extend(kiosk());\n *\n * const ownedKiosks = await client.kiosk.getOwnedKiosks({ address: '0x...' });\n * ```\n */\nexport function kiosk<const Name extends string = 'kiosk'>({\n\tname = 'kiosk' as Name,\n\tpackageIds,\n}: KioskExtensionOptions<Name> = {}) {\n\treturn {\n\t\tname,\n\t\tregister: (client: ClientWithCoreApi) => {\n\t\t\treturn new KioskClient({\n\t\t\t\tclient,\n\t\t\t\tnetwork: client.network,\n\t\t\t\tpackageIds,\n\t\t\t});\n\t\t},\n\t};\n}\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\tclient: ClientWithCoreApi;\n\tnetwork: SuiClientTypes.Network;\n\trules: TransferPolicyRule[];\n\tpackageIds?: BaseRulePackageIds;\n\n\tconstructor(options: KioskClientOptions) {\n\t\tthis.client = options.client;\n\t\tthis.network = options.network;\n\t\tthis.rules = rules; // add all the default rules.\n\t\tthis.packageIds = options.packageIds;\n\n\t\t// Add the custom Package Ids too on the rule list.\n\t\t// Only adds the rules that are passed in the packageId object.\n\t\tif (options.packageIds) this.rules.push(...getBaseRules(options.packageIds));\n\t}\n\n\t/// Querying\n\n\t/**\n\t * Get an addresses's owned kiosks.\n\t * @param address The address for which we want to retrieve the kiosks.\n\t * @param pagination Optional pagination arguments.\n\t * @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.\n\t */\n\tasync getOwnedKiosks({\n\t\taddress,\n\t\tpagination,\n\t}: {\n\t\taddress: string;\n\t\tpagination?: PaginationArguments<string>;\n\t}): Promise<OwnedKiosks> {\n\t\tconst personalPackageId =\n\t\t\tthis.packageIds?.personalKioskRulePackageId || PERSONAL_KIOSK_RULE_ADDRESS[this.network];\n\n\t\treturn getOwnedKiosks(this.client, address, {\n\t\t\tpagination,\n\t\t\tpersonalKioskType: personalPackageId\n\t\t\t\t? `${personalPackageId}::personal_kiosk::PersonalKioskCap`\n\t\t\t\t: '',\n\t\t});\n\t}\n\n\t/**\n\t * Fetches the kiosk contents.\n\t * @param id The ID of the kiosk to fetch.\n\t * @param options Optional to control the fetch behavior.\n\t * @returns\n\t */\n\tasync getKiosk({ id, options }: { id: string; options?: FetchKioskOptions }): Promise<KioskData> {\n\t\treturn (await fetchKiosk(this.client, id, {}, options || {})).data;\n\t}\n\n\t/**\n\t * Fetch the extension data (if any) for a kiosk, by type\n\t * @param kioskId The ID of the kiosk to lookup\n\t * @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)\n\t */\n\tasync getKioskExtension({ kioskId, type }: { kioskId: string; type: string }) {\n\t\treturn fetchKioskExtension(this.client, kioskId, type);\n\t}\n\n\t/**\n\t * Query the Transfer Policy(ies) for type `T`.\n\t * @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)\n\t */\n\tasync getTransferPolicies({ type }: { type: string }) {\n\t\treturn queryTransferPolicy(this.client, type);\n\t}\n\n\t/**\n\t * Query all the owned transfer policies for an address.\n\t * Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.\n\t * @param address The address we're searching the owned transfer policies for.\n\t */\n\tasync getOwnedTransferPolicies({ address }: { address: string }) {\n\t\treturn queryOwnedTransferPolicies(this.client, address);\n\t}\n\n\t/**\n\t * Query the Transfer Policy Cap for type `T`, owned by `address`\n\t * @param type The Type `T` for the object\n\t * @param address The address that owns the cap.\n\t */\n\tasync getOwnedTransferPoliciesByType({ type, address }: { type: string; address: string }) {\n\t\treturn queryTransferPolicyCapsByType(this.client, address, type);\n\t}\n\n\t// Someone would just have to create a `kiosk-client.ts` file in their project, initialize a KioskClient\n\t// and call the `addRuleResolver` function. Each rule has a `resolve` function.\n\t// The resolve function is automatically called on `purchaseAndResolve` function call.\n\taddRuleResolver(rule: TransferPolicyRule) {\n\t\tif (this.rules.find((x) => x.rule === rule.rule))\n\t\t\tthrow new Error(`Rule ${rule.rule} resolver already exists.`);\n\t\tthis.rules.push(rule);\n\t}\n\n\t/**\n\t * A convenient helper to get the packageIds for our supported ruleset,\n\t * based on `kioskClient` configuration.\n\t */\n\tgetRulePackageId(\n\t\trule:\n\t\t\t| 'kioskLockRulePackageId'\n\t\t\t| 'royaltyRulePackageId'\n\t\t\t| 'personalKioskRulePackageId'\n\t\t\t| 'floorPriceRulePackageId',\n\t) {\n\t\tconst rules = this.packageIds || {};\n\t\tconst network = this.network;\n\n\t\t/// Check existence of rule based on network and throw an error if it's not found.\n\t\t/// We always have a fallback for testnet or mainnet.\n\t\tif (!rules[rule] && network !== 'mainnet' && network !== 'testnet') {\n\t\t\tthrow new Error(`Missing packageId for rule ${rule}`);\n\t\t}\n\n\t\tswitch (rule) {\n\t\t\tcase 'kioskLockRulePackageId':\n\t\t\t\treturn rules[rule] || KIOSK_LOCK_RULE_ADDRESS[network];\n\t\t\tcase 'royaltyRulePackageId':\n\t\t\t\treturn rules[rule] || ROYALTY_RULE_ADDRESS[network];\n\t\t\tcase 'personalKioskRulePackageId':\n\t\t\t\treturn rules[rule] || PERSONAL_KIOSK_RULE_ADDRESS[network];\n\t\t\tcase 'floorPriceRulePackageId':\n\t\t\t\treturn rules[rule] || FLOOR_PRICE_RULE_ADDRESS[network];\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,MAA2C,EAC1D,OAAO,SACP,eACgC,EAAE,EAAE;AACpC,QAAO;EACN;EACA,WAAW,WAA8B;AACxC,UAAO,IAAI,YAAY;IACtB;IACA,SAAS,OAAO;IAChB;IACA,CAAC;;EAEH;;;;;;;;AASF,IAAa,cAAb,MAAyB;CAMxB,YAAY,SAA6B;AACxC,OAAK,SAAS,QAAQ;AACtB,OAAK,UAAU,QAAQ;AACvB,OAAK,QAAQ;AACb,OAAK,aAAa,QAAQ;AAI1B,MAAI,QAAQ,WAAY,MAAK,MAAM,KAAK,GAAG,aAAa,QAAQ,WAAW,CAAC;;;;;;;;CAW7E,MAAM,eAAe,EACpB,SACA,cAIwB;EACxB,MAAM,oBACL,KAAK,YAAY,8BAA8B,4BAA4B,KAAK;AAEjF,SAAO,eAAe,KAAK,QAAQ,SAAS;GAC3C;GACA,mBAAmB,oBAChB,GAAG,kBAAkB,sCACrB;GACH,CAAC;;;;;;;;CASH,MAAM,SAAS,EAAE,IAAI,WAA4E;AAChG,UAAQ,MAAM,WAAW,KAAK,QAAQ,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE;;;;;;;CAQ/D,MAAM,kBAAkB,EAAE,SAAS,QAA2C;AAC7E,SAAO,oBAAoB,KAAK,QAAQ,SAAS,KAAK;;;;;;CAOvD,MAAM,oBAAoB,EAAE,QAA0B;AACrD,SAAO,oBAAoB,KAAK,QAAQ,KAAK;;;;;;;CAQ9C,MAAM,yBAAyB,EAAE,WAAgC;AAChE,SAAO,2BAA2B,KAAK,QAAQ,QAAQ;;;;;;;CAQxD,MAAM,+BAA+B,EAAE,MAAM,WAA8C;AAC1F,SAAO,8BAA8B,KAAK,QAAQ,SAAS,KAAK;;CAMjE,gBAAgB,MAA0B;AACzC,MAAI,KAAK,MAAM,MAAM,MAAM,EAAE,SAAS,KAAK,KAAK,CAC/C,OAAM,IAAI,MAAM,QAAQ,KAAK,KAAK,2BAA2B;AAC9D,OAAK,MAAM,KAAK,KAAK;;;;;;CAOtB,iBACC,MAKC;EACD,MAAMA,UAAQ,KAAK,cAAc,EAAE;EACnC,MAAM,UAAU,KAAK;AAIrB,MAAI,CAACA,QAAM,SAAS,YAAY,aAAa,YAAY,UACxD,OAAM,IAAI,MAAM,8BAA8B,OAAO;AAGtD,UAAQ,MAAR;GACC,KAAK,yBACJ,QAAOA,QAAM,SAAS,wBAAwB;GAC/C,KAAK,uBACJ,QAAOA,QAAM,SAAS,qBAAqB;GAC5C,KAAK,6BACJ,QAAOA,QAAM,SAAS,4BAA4B;GACnD,KAAK,0BACJ,QAAOA,QAAM,SAAS,yBAAyB"}
@@ -0,0 +1,236 @@
1
+ import { ItemId, ItemReference, ItemValue, KioskOwnerCap, Price, PurchaseOptions } from "../types/kiosk.mjs";
2
+ import { KioskClient } from "./kiosk-client.mjs";
3
+ import { ObjectArgument } from "../types/index.mjs";
4
+ import { Transaction, TransactionArgument, TransactionObjectArgument } from "@mysten/sui/transactions";
5
+
6
+ //#region src/client/kiosk-transaction.d.ts
7
+ type KioskTransactionParams = {
8
+ /** The Transaction for this run */
9
+ transaction: Transaction;
10
+ /**
11
+ * You can create a new KioskClient by calling `new KioskClient()`
12
+ */
13
+ kioskClient: KioskClient;
14
+ /**
15
+ * You can optionally pass in the `cap` as returned
16
+ * from `kioskClient.getOwnedKiosks` when initializing the client
17
+ * Otherwise, you can set it by calling `kioskTransaction.setCap()`
18
+ */
19
+ cap?: KioskOwnerCap;
20
+ };
21
+ /**
22
+ * A helper for building transactions that involve kiosk.
23
+ */
24
+ declare class KioskTransaction {
25
+ #private;
26
+ transaction: Transaction;
27
+ kioskClient: KioskClient;
28
+ kiosk?: TransactionObjectArgument;
29
+ kioskCap?: TransactionObjectArgument;
30
+ constructor({
31
+ transaction,
32
+ kioskClient,
33
+ cap
34
+ }: KioskTransactionParams);
35
+ /**
36
+ * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
37
+ * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.
38
+ * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
39
+ */
40
+ create(): this;
41
+ /**
42
+ * Creates a personal kiosk & shares it.
43
+ * The `PersonalKioskCap` is transferred to the signer.
44
+ * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.
45
+ */
46
+ createPersonal(borrow?: boolean): this;
47
+ /**
48
+ * Converts a kiosk to a Personal (Soulbound) Kiosk.
49
+ * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.
50
+ */
51
+ convertToPersonal(borrow?: boolean): this;
52
+ /**
53
+ * Single function way to create a kiosk, share it and transfer the cap to the specified address.
54
+ */
55
+ createAndShare(address: string): this;
56
+ /**
57
+ * Shares the kiosk.
58
+ */
59
+ share(): this;
60
+ /**
61
+ * Should be called only after `create` is called.
62
+ * It shares the kiosk & transfers the cap to the specified address.
63
+ */
64
+ shareAndTransferCap(address: string): this;
65
+ /**
66
+ * A function to borrow an item from a kiosk & execute any function with it.
67
+ * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.
68
+ */
69
+ borrowTx({
70
+ itemType,
71
+ itemId
72
+ }: ItemId, callback: (item: TransactionArgument) => void): this;
73
+ /**
74
+ * Borrows an item from the kiosk.
75
+ * This will fail if the item is listed for sale.
76
+ *
77
+ * Requires calling `return`.
78
+ */
79
+ borrow({
80
+ itemType,
81
+ itemId
82
+ }: ItemId): [TransactionArgument, TransactionArgument];
83
+ /**
84
+ * Returns the item back to the kiosk.
85
+ * Accepts the parameters returned from the `borrow` function.
86
+ */
87
+ return({
88
+ itemType,
89
+ item,
90
+ promise
91
+ }: ItemValue & {
92
+ promise: TransactionArgument;
93
+ }): this;
94
+ /**
95
+ * A function to withdraw from kiosk
96
+ * @param address Where to transfer the coin.
97
+ * @param amount The amount we aim to withdraw.
98
+ */
99
+ withdraw(address: string, amount?: string | bigint | number): this;
100
+ /**
101
+ * A function to place an item in the kiosk.
102
+ * @param itemType The type `T` of the item
103
+ * @param item The ID or Transaction Argument of the item
104
+ */
105
+ place({
106
+ itemType,
107
+ item
108
+ }: ItemReference): this;
109
+ /**
110
+ * A function to place an item in the kiosk and list it for sale in one transaction.
111
+ * @param itemType The type `T` of the item
112
+ * @param item The ID or Transaction Argument of the item
113
+ * @param price The price in MIST
114
+ */
115
+ placeAndList({
116
+ itemType,
117
+ item,
118
+ price
119
+ }: ItemReference & Price): this;
120
+ /**
121
+ * A function to list an item in the kiosk.
122
+ * @param itemType The type `T` of the item
123
+ * @param itemId The ID of the item
124
+ * @param price The price in MIST
125
+ */
126
+ list({
127
+ itemType,
128
+ itemId,
129
+ price
130
+ }: ItemId & {
131
+ price: string | bigint;
132
+ }): this;
133
+ /**
134
+ * A function to delist an item from the kiosk.
135
+ * @param itemType The type `T` of the item
136
+ * @param itemId The ID of the item
137
+ */
138
+ delist({
139
+ itemType,
140
+ itemId
141
+ }: ItemId): this;
142
+ /**
143
+ * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.
144
+ * @param itemType The type `T` of the item
145
+ * @param itemId The ID of the item
146
+ */
147
+ take({
148
+ itemType,
149
+ itemId
150
+ }: ItemId): TransactionObjectArgument;
151
+ /**
152
+ * Transfer a non-locked/non-listed item to an address.
153
+ *
154
+ * @param itemType The type `T` of the item
155
+ * @param itemId The ID of the item
156
+ * @param address The destination address
157
+ */
158
+ transfer({
159
+ itemType,
160
+ itemId,
161
+ address
162
+ }: ItemId & {
163
+ address: string;
164
+ }): this;
165
+ /**
166
+ * A function to take lock an item in the kiosk.
167
+ * @param itemType The type `T` of the item
168
+ * @param item The ID or Transaction Argument of the item
169
+ * @param itemId The ID of the item - Deprecated: Use `item` instead.
170
+ * @param policy The Policy ID or Transaction Argument for item T
171
+ */
172
+ lock({
173
+ itemType,
174
+ item,
175
+ itemId,
176
+ policy
177
+ }: ItemReference & {
178
+ policy: ObjectArgument;
179
+ itemId?: string;
180
+ }): this;
181
+ /**
182
+ * Purchase an item from a seller's kiosk.
183
+ * Returns [item, transferRequest]
184
+ * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`
185
+ * @param itemType The type `T` of the item
186
+ * @param itemId The ID of the item
187
+ * @param price The price in MIST
188
+ * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
189
+ */
190
+ purchase({
191
+ itemType,
192
+ itemId,
193
+ price,
194
+ sellerKiosk
195
+ }: ItemId & Price & {
196
+ sellerKiosk: ObjectArgument;
197
+ }): [TransactionObjectArgument, TransactionObjectArgument];
198
+ /**
199
+ * A function to purchase and resolve a transfer policy.
200
+ * If the transfer policy has the `lock` rule, the item is locked in the kiosk.
201
+ * Otherwise, the item is placed in the kiosk.
202
+ * @param itemType The type of the item
203
+ * @param itemId The id of the item
204
+ * @param price The price of the specified item
205
+ * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.
206
+ * @param extraArgs Used to pass arguments for custom rule resolvers.
207
+ */
208
+ purchaseAndResolve({
209
+ itemType,
210
+ itemId,
211
+ price,
212
+ sellerKiosk,
213
+ extraArgs
214
+ }: ItemId & Price & {
215
+ sellerKiosk: ObjectArgument;
216
+ } & PurchaseOptions): Promise<this>;
217
+ /**
218
+ * A function to setup the client using an existing `ownerCap`,
219
+ * as return from the `kioskClient.getOwnedKiosks` function.
220
+ * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.
221
+ */
222
+ setCap(cap: KioskOwnerCap): this | undefined;
223
+ /**
224
+ * A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
225
+ * `PersonalKioskCap`, in case we are operating on a personal kiosk.
226
+ * It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
227
+ */
228
+ finalize(): void;
229
+ setKioskCap(cap: TransactionObjectArgument): this;
230
+ setKiosk(kiosk: TransactionObjectArgument): this;
231
+ getKiosk(): TransactionObjectArgument;
232
+ getKioskCap(): TransactionObjectArgument;
233
+ }
234
+ //#endregion
235
+ export { KioskTransaction, KioskTransactionParams };
236
+ //# sourceMappingURL=kiosk-transaction.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kiosk-transaction.d.mts","names":[],"sources":["../../src/client/kiosk-transaction.ts"],"sourcesContent":[],"mappings":";;;;;;KAyBY,sBAAA;;eAEE;EAFF;;;EAaL,WAAA,EANO,WAMP;EAAa;AAMpB;;;;EAIY,GAAA,CAAA,EAVL,aAUK;CAYG;;;;AAsGH,cAtHC,gBAAA,CAsHD;EAAU,CAAA,OAAA;EAAU,WAAA,EArHlB,WAqHkB;EAAyB,WAAA,EApH3C,WAoH2C;EAoB/C,KAAA,CAAA,EAvID,yBAuIC;EAAU,QAAA,CAAA,EAtIR,yBAsIQ;EAAU,WAAA,CAAA;IAAA,WAAA;IAAA,WAAA;IAAA;EAAA,CAAA,EA1HkB,sBA0HlB;EAAU;;;;;EAgBH,MAAA,CAAA,CAAA,EAAA,IAAA;EAAuB;;;;;EAmDlC,cAAA,CAAA,MAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAM;;;;EAmBd,iBAAA,CAAA,MAAA,CAAA,EAAA,OAAA,CAAA,EAAA,IAAA;EAAQ;;;EAiBN,cAAA,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAAU;;;EAiBF,KAAA,CAAA,CAAA,EAAA,IAAA;EAAS;;;;EAkBI,mBAAA,CAAA,OAAA,EAAA,MAAA,CAAA,EAAA,IAAA;EAgBvC;;;;EAIE,QAAA,CAAA;IAAA,QAAA;IAAA;EAAA,CAAA,EAlL4B,MAkL5B,EAAA,QAAA,EAAA,CAAA,IAAA,EAlLqD,mBAkLrD,EAAA,GAAA,IAAA,CAAA,EAAA,IAAA;EAA0B;;;;;;EA+BjB,MAAA,CAAA;IAAA,QAAA;IAAA;EAAA,CAAA,EA7LiB,MA6LjB,CAAA,EAAA,CA7L2B,mBA6L3B,EA7LgD,mBA6LhD,CAAA;EAAuB;;;;EA6BlC,MAAA,CAAA;IAAA,QAAA;IAAA,IAAA;IAAA;EAEA,CAFA,EA1MmC,SA0MnC,GAAA;IACA,OAAA,EA3M0D,mBA2M1D;EACA,CAAA,CAAA,EAAA,IAAA;EACA;;;;;EACoE,QAAA,CAAA,OAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA,MAAA,CAAA,EAAA,IAAA;EAiEzD;;;;;EAyFD,KAAA,CAAA;IAAA,QAAA;IAAA;EAAA,CAAA,EAvUe,aAuUf,CAAA,EAAA,IAAA;;;;;;;;;;;KArT6B,gBAAgB;;;;;;;;;;;KAmBtB;;;;;;;;;;;KAiBL;;;;;;;;;KAiBF,SAAS;;;;;;;;;;;;KAkBI;;;;;;;;;;;;;;;KAoBrC;YAA0B;;;;;;;;;;;;;;;;;KA+B1B,SAAS;iBAAuB;OAClC,2BACA;;;;;;;;;;;;;;;;;KA+BE,SAAS;iBAAuB;MAAmB,kBAAe;;;;;;cAiEzD;;;;;;;mBAgEK;kBAMD;cAUR;iBASG"}