@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kiosk.mjs","names":[],"sources":["../../../../../src/contracts/kiosk/deps/sui/kiosk.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Kiosk is a primitive for building safe, decentralized and trustless trading\n * experiences. It allows storing and trading any types of assets as long as the\n * creator of these assets implements a `TransferPolicy` for them.\n *\n * ### Principles and philosophy:\n *\n * - Kiosk provides guarantees of \"true ownership\"; - just like single owner\n * objects, assets stored in the Kiosk can only be managed by the Kiosk owner.\n * Only the owner can `place`, `take`, `list`, perform any other actions on\n * assets in the Kiosk.\n *\n * - Kiosk aims to be generic - allowing for a small set of default behaviors and\n * not imposing any restrictions on how the assets can be traded. The only\n * default scenario is a `list` + `purchase` flow; any other trading logic can be\n * implemented on top using the `list_with_purchase_cap` (and a matching\n * `purchase_with_cap`) flow.\n *\n * - For every transaction happening with a third party a `TransferRequest` is\n * created - this way creators are fully in control of the trading experience.\n *\n * ### Asset states in the Kiosk:\n *\n * - `placed` - An asset is `place`d into the Kiosk and can be `take`n out by the\n * Kiosk owner; it's freely tradable and modifiable via the `borrow_mut` and\n * `borrow_val` functions.\n *\n * - `locked` - Similar to `placed` except that `take` is disabled and the only way\n * to move the asset out of the Kiosk is to `list` it or `list_with_purchase_cap`\n * therefore performing a trade (issuing a `TransferRequest`). The check on the\n * `lock` function makes sure that the `TransferPolicy` exists to not lock the\n * item in a `Kiosk` forever.\n *\n * - `listed` - A `place`d or a `lock`ed item can be `list`ed for a fixed price\n * allowing anyone to `purchase` it from the Kiosk. While listed, an item can not\n * be taken or modified. However, an immutable borrow via `borrow` call is still\n * available. The `delist` function returns the asset to the previous state.\n *\n * - `listed_exclusively` - An item is listed via the `list_with_purchase_cap`\n * function (and a `PurchaseCap` is created). While listed this way, an item can\n * not be `delist`-ed unless a `PurchaseCap` is returned. All actions available\n * at this item state require a `PurchaseCap`:\n *\n * 1. `purchase_with_cap` - to purchase the item for a price equal or higher than\n * the `min_price` set in the `PurchaseCap`.\n * 2. `return_purchase_cap` - to return the `PurchaseCap` and return the asset\n * into the previous state.\n *\n * When an item is listed exclusively it cannot be modified nor taken and losing a\n * `PurchaseCap` would lock the item in the Kiosk forever. Therefore, it is\n * recommended to only use `PurchaseCap` functionality in trusted applications and\n * not use it for direct trading (eg sending to another account).\n *\n * ### Using multiple Transfer Policies for different \"tracks\":\n *\n * Every `purchase` or `purchase_with_purchase_cap` creates a `TransferRequest` hot\n * potato which must be resolved in a matching `TransferPolicy` for the transaction\n * to pass. While the default scenario implies that there should be a single\n * `TransferPolicy<T>` for `T`; it is possible to have multiple, each one having\n * its own set of rules.\n *\n * ### Examples:\n *\n * - I create one `TransferPolicy` with \"Royalty Rule\" for everyone\n * - I create a special `TransferPolicy` for bearers of a \"Club Membership\" object\n * so they don't have to pay anything\n * - I create and wrap a `TransferPolicy` so that players of my game can transfer\n * items between `Kiosk`s in game without any charge (and maybe not even paying\n * the price with a 0 SUI PurchaseCap)\n *\n * ```\n * Kiosk -> (Item, TransferRequest)\n * ... TransferRequest ------> Common Transfer Policy\n * ... TransferRequest ------> In-game Wrapped Transfer Policy\n * ... TransferRequest ------> Club Membership Transfer Policy\n * ```\n *\n * See `transfer_policy` module for more details on how they function.\n */\n\nimport { MoveStruct } from '../../../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nconst $moduleName = '0x2::kiosk';\nexport const KioskOwnerCap = new MoveStruct({\n\tname: `${$moduleName}::KioskOwnerCap`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\tfor: bcs.Address,\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAM,cAAc;AACpB,MAAa,gBAAgB,IAAI,WAAW;CAC3C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,IAAI,IAAI;EACR,KAAK,IAAI;EACT;CACD,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+
4
+ //#region src/contracts/kiosk/floor_price_rule.ts
5
+ /**************************************************************
6
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
+ **************************************************************/
8
+ /**
9
+ * Description: This module defines a Rule which sets the floor price for items of
10
+ * type T.
11
+ *
12
+ * Configuration:
13
+ *
14
+ * - floor_price - the floor price in MIST.
15
+ *
16
+ * Use cases:
17
+ *
18
+ * - Defining a floor price for all trades of type T.
19
+ * - Prevent trading of locked items with low amounts (e.g. by using purchase_cap).
20
+ */
21
+ const $moduleName = "@local-pkg/kiosk::floor_price_rule";
22
+ const Rule = new MoveStruct({
23
+ name: `${$moduleName}::Rule`,
24
+ fields: { dummy_field: bcs.bool() }
25
+ });
26
+ const Config = new MoveStruct({
27
+ name: `${$moduleName}::Config`,
28
+ fields: { floor_price: bcs.u64() }
29
+ });
30
+ /**
31
+ * Creator action: Add the Floor Price Rule for the `T`. Pass in the
32
+ * `TransferPolicy`, `TransferPolicyCap` and `floor_price`.
33
+ */
34
+ function add(options) {
35
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
36
+ const argumentsTypes = [
37
+ null,
38
+ null,
39
+ "u64"
40
+ ];
41
+ const parameterNames = [
42
+ "policy",
43
+ "cap",
44
+ "floorPrice"
45
+ ];
46
+ return (tx) => tx.moveCall({
47
+ package: packageAddress,
48
+ module: "floor_price_rule",
49
+ function: "add",
50
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
51
+ typeArguments: options.typeArguments
52
+ });
53
+ }
54
+ /** Buyer action: Prove that the amount is higher or equal to the floor_price. */
55
+ function prove(options) {
56
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
57
+ const argumentsTypes = [null, null];
58
+ const parameterNames = ["policy", "request"];
59
+ return (tx) => tx.moveCall({
60
+ package: packageAddress,
61
+ module: "floor_price_rule",
62
+ function: "prove",
63
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
64
+ typeArguments: options.typeArguments
65
+ });
66
+ }
67
+
68
+ //#endregion
69
+ export { add, prove };
70
+ //# sourceMappingURL=floor_price_rule.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floor_price_rule.mjs","names":[],"sources":["../../../src/contracts/kiosk/floor_price_rule.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Description: This module defines a Rule which sets the floor price for items of\n * type T.\n *\n * Configuration:\n *\n * - floor_price - the floor price in MIST.\n *\n * Use cases:\n *\n * - Defining a floor price for all trades of type T.\n * - Prevent trading of locked items with low amounts (e.g. by using purchase_cap).\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nconst $moduleName = '@local-pkg/kiosk::floor_price_rule';\nexport const Rule = new MoveStruct({\n\tname: `${$moduleName}::Rule`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const Config = new MoveStruct({\n\tname: `${$moduleName}::Config`,\n\tfields: {\n\t\tfloor_price: bcs.u64(),\n\t},\n});\nexport interface AddArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n\tfloorPrice: RawTransactionArgument<number | bigint>;\n}\nexport interface AddOptions {\n\tpackage?: string;\n\targuments:\n\t\t| AddArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\tcap: RawTransactionArgument<string>,\n\t\t\t\tfloorPrice: RawTransactionArgument<number | bigint>,\n\t\t ];\n\ttypeArguments: [string];\n}\n/**\n * Creator action: Add the Floor Price Rule for the `T`. Pass in the\n * `TransferPolicy`, `TransferPolicyCap` and `floor_price`.\n */\nexport function add(options: AddOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'cap', 'floorPrice'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'floor_price_rule',\n\t\t\tfunction: 'add',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ProveArguments {\n\tpolicy: RawTransactionArgument<string>;\n\trequest: RawTransactionArgument<string>;\n}\nexport interface ProveOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ProveArguments\n\t\t| [policy: RawTransactionArgument<string>, request: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/** Buyer action: Prove that the amount is higher or equal to the floor_price. */\nexport function prove(options: ProveOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'request'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'floor_price_rule',\n\t\t\tfunction: 'prove',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,cAAc;AACpB,MAAa,OAAO,IAAI,WAAW;CAClC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,MAAM,EACvB;CACD,CAAC;AACF,MAAa,SAAS,IAAI,WAAW;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,KAAK,EACtB;CACD,CAAC;;;;;AAqBF,SAAgB,IAAI,SAAqB;CACxC,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB;EAAC;EAAM;EAAM;EAAM;CAC1C,MAAM,iBAAiB;EAAC;EAAU;EAAO;EAAa;AACtD,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC;;;AAcJ,SAAgB,MAAM,SAAuB;CAC5C,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,MAAM,KAAK;CACnC,MAAM,iBAAiB,CAAC,UAAU,UAAU;AAC5C,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+
4
+ //#region src/contracts/kiosk/kiosk_lock_rule.ts
5
+ /**************************************************************
6
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
+ **************************************************************/
8
+ /**
9
+ * Description: This module defines a Rule which forces buyers to put the purchased
10
+ * item into the Kiosk and lock it. The most common use case for the Rule is making
11
+ * sure an item never leaves Kiosks and has policies enforced on every transfer.
12
+ *
13
+ * Configuration:
14
+ *
15
+ * - None
16
+ *
17
+ * Use cases:
18
+ *
19
+ * - Enforcing policies on every trade
20
+ * - Making sure an item never leaves the Kiosk / certain ecosystem
21
+ *
22
+ * Notes:
23
+ *
24
+ * - "locking" mechanic disallows the `kiosk::take` function and forces the owner
25
+ * to use `list` or `list_with_purchase_cap` methods if they wish to move the
26
+ * item somewhere else.
27
+ */
28
+ const $moduleName = "@local-pkg/kiosk::kiosk_lock_rule";
29
+ const Rule = new MoveStruct({
30
+ name: `${$moduleName}::Rule`,
31
+ fields: { dummy_field: bcs.bool() }
32
+ });
33
+ const Config = new MoveStruct({
34
+ name: `${$moduleName}::Config`,
35
+ fields: { dummy_field: bcs.bool() }
36
+ });
37
+ /**
38
+ * Creator: Adds a `kiosk_lock_rule` Rule to the `TransferPolicy` forcing buyers to
39
+ * lock the item in a Kiosk on purchase.
40
+ */
41
+ function add(options) {
42
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
43
+ const argumentsTypes = [null, null];
44
+ const parameterNames = ["policy", "cap"];
45
+ return (tx) => tx.moveCall({
46
+ package: packageAddress,
47
+ module: "kiosk_lock_rule",
48
+ function: "add",
49
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
50
+ typeArguments: options.typeArguments
51
+ });
52
+ }
53
+ /**
54
+ * Buyer: Prove the item was locked in the Kiosk to get the receipt and unblock the
55
+ * transfer request confirmation.
56
+ */
57
+ function prove(options) {
58
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
59
+ const argumentsTypes = [null, null];
60
+ const parameterNames = ["request", "kiosk"];
61
+ return (tx) => tx.moveCall({
62
+ package: packageAddress,
63
+ module: "kiosk_lock_rule",
64
+ function: "prove",
65
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
66
+ typeArguments: options.typeArguments
67
+ });
68
+ }
69
+
70
+ //#endregion
71
+ export { add, prove };
72
+ //# sourceMappingURL=kiosk_lock_rule.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kiosk_lock_rule.mjs","names":[],"sources":["../../../src/contracts/kiosk/kiosk_lock_rule.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Description: This module defines a Rule which forces buyers to put the purchased\n * item into the Kiosk and lock it. The most common use case for the Rule is making\n * sure an item never leaves Kiosks and has policies enforced on every transfer.\n *\n * Configuration:\n *\n * - None\n *\n * Use cases:\n *\n * - Enforcing policies on every trade\n * - Making sure an item never leaves the Kiosk / certain ecosystem\n *\n * Notes:\n *\n * - \"locking\" mechanic disallows the `kiosk::take` function and forces the owner\n * to use `list` or `list_with_purchase_cap` methods if they wish to move the\n * item somewhere else.\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nconst $moduleName = '@local-pkg/kiosk::kiosk_lock_rule';\nexport const Rule = new MoveStruct({\n\tname: `${$moduleName}::Rule`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const Config = new MoveStruct({\n\tname: `${$moduleName}::Config`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport interface AddArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n}\nexport interface AddOptions {\n\tpackage?: string;\n\targuments:\n\t\t| AddArguments\n\t\t| [policy: RawTransactionArgument<string>, cap: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Creator: Adds a `kiosk_lock_rule` Rule to the `TransferPolicy` forcing buyers to\n * lock the item in a Kiosk on purchase.\n */\nexport function add(options: AddOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'cap'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'kiosk_lock_rule',\n\t\t\tfunction: 'add',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ProveArguments {\n\trequest: RawTransactionArgument<string>;\n\tkiosk: RawTransactionArgument<string>;\n}\nexport interface ProveOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ProveArguments\n\t\t| [request: RawTransactionArgument<string>, kiosk: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Buyer: Prove the item was locked in the Kiosk to get the receipt and unblock the\n * transfer request confirmation.\n */\nexport function prove(options: ProveOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['request', 'kiosk'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'kiosk_lock_rule',\n\t\t\tfunction: 'prove',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,cAAc;AACpB,MAAa,OAAO,IAAI,WAAW;CAClC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,MAAM,EACvB;CACD,CAAC;AACF,MAAa,SAAS,IAAI,WAAW;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,MAAM,EACvB;CACD,CAAC;;;;;AAgBF,SAAgB,IAAI,SAAqB;CACxC,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,MAAM,KAAK;CACnC,MAAM,iBAAiB,CAAC,UAAU,MAAM;AACxC,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC;;;;;;AAiBJ,SAAgB,MAAM,SAAuB;CAC5C,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,MAAM,KAAK;CACnC,MAAM,iBAAiB,CAAC,WAAW,QAAQ;AAC3C,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { KioskOwnerCap } from "./deps/sui/kiosk.mjs";
3
+ import { bcs } from "@mysten/sui/bcs";
4
+
5
+ //#region src/contracts/kiosk/personal_kiosk.ts
6
+ /**************************************************************
7
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
8
+ **************************************************************/
9
+ /**
10
+ * Description: This module provides a wrapper for the KioskOwnerCap that makes the
11
+ * Kiosk non-transferable and "owned".
12
+ */
13
+ const $moduleName = "@local-pkg/kiosk::personal_kiosk";
14
+ const PersonalKioskCap = new MoveStruct({
15
+ name: `${$moduleName}::PersonalKioskCap`,
16
+ fields: {
17
+ id: bcs.Address,
18
+ cap: bcs.option(KioskOwnerCap)
19
+ }
20
+ });
21
+ const Borrow = new MoveStruct({
22
+ name: `${$moduleName}::Borrow`,
23
+ fields: {
24
+ cap_id: bcs.Address,
25
+ owned_id: bcs.Address
26
+ }
27
+ });
28
+ const OwnerMarker = new MoveStruct({
29
+ name: `${$moduleName}::OwnerMarker`,
30
+ fields: { dummy_field: bcs.bool() }
31
+ });
32
+ const NewPersonalKiosk = new MoveStruct({
33
+ name: `${$moduleName}::NewPersonalKiosk`,
34
+ fields: { kiosk_id: bcs.Address }
35
+ });
36
+ /**
37
+ * Wrap the KioskOwnerCap making the Kiosk "owned" and non-transferable. The
38
+ * `PersonalKioskCap` is returned to allow chaining within a PTB, but the value
39
+ * must be consumed by the `transfer_to_sender` call in any case.
40
+ */
41
+ function _new(options) {
42
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
43
+ const argumentsTypes = [null, null];
44
+ const parameterNames = ["kiosk", "cap"];
45
+ return (tx) => tx.moveCall({
46
+ package: packageAddress,
47
+ module: "personal_kiosk",
48
+ function: "new",
49
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
50
+ });
51
+ }
52
+ /**
53
+ * Borrow the `KioskOwnerCap` from the `PersonalKioskCap` object; `Borrow`
54
+ * hot-potato makes sure that the Cap is returned via `return_val` call.
55
+ */
56
+ function borrowVal(options) {
57
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
58
+ const argumentsTypes = [null];
59
+ const parameterNames = ["self"];
60
+ return (tx) => tx.moveCall({
61
+ package: packageAddress,
62
+ module: "personal_kiosk",
63
+ function: "borrow_val",
64
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
65
+ });
66
+ }
67
+ /** Return the Cap to the PersonalKioskCap object. */
68
+ function returnVal(options) {
69
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
70
+ const argumentsTypes = [
71
+ null,
72
+ null,
73
+ null
74
+ ];
75
+ const parameterNames = [
76
+ "self",
77
+ "cap",
78
+ "borrow"
79
+ ];
80
+ return (tx) => tx.moveCall({
81
+ package: packageAddress,
82
+ module: "personal_kiosk",
83
+ function: "return_val",
84
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
85
+ });
86
+ }
87
+ /** Transfer the `PersonalKioskCap` to the transaction sender. */
88
+ function transferToSender(options) {
89
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
90
+ const argumentsTypes = [null];
91
+ const parameterNames = ["self"];
92
+ return (tx) => tx.moveCall({
93
+ package: packageAddress,
94
+ module: "personal_kiosk",
95
+ function: "transfer_to_sender",
96
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
97
+ });
98
+ }
99
+
100
+ //#endregion
101
+ export { PersonalKioskCap, _new, borrowVal, returnVal, transferToSender };
102
+ //# sourceMappingURL=personal_kiosk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"personal_kiosk.mjs","names":["kiosk.KioskOwnerCap"],"sources":["../../../src/contracts/kiosk/personal_kiosk.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Description: This module provides a wrapper for the KioskOwnerCap that makes the\n * Kiosk non-transferable and \"owned\".\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nimport * as kiosk from './deps/sui/kiosk.js';\nconst $moduleName = '@local-pkg/kiosk::personal_kiosk';\nexport const PersonalKioskCap = new MoveStruct({\n\tname: `${$moduleName}::PersonalKioskCap`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\tcap: bcs.option(kiosk.KioskOwnerCap),\n\t},\n});\nexport const Borrow = new MoveStruct({\n\tname: `${$moduleName}::Borrow`,\n\tfields: {\n\t\tcap_id: bcs.Address,\n\t\towned_id: bcs.Address,\n\t},\n});\nexport const OwnerMarker = new MoveStruct({\n\tname: `${$moduleName}::OwnerMarker`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const NewPersonalKiosk = new MoveStruct({\n\tname: `${$moduleName}::NewPersonalKiosk`,\n\tfields: {\n\t\tkiosk_id: bcs.Address,\n\t},\n});\nexport interface DefaultArguments {\n\tkiosk: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n}\nexport interface DefaultOptions {\n\tpackage?: string;\n\targuments:\n\t\t| DefaultArguments\n\t\t| [kiosk: RawTransactionArgument<string>, cap: RawTransactionArgument<string>];\n}\n/** The default setup for the PersonalKioskCap. */\nexport function _default(options: DefaultOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['kiosk', 'cap'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'default',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NewArguments {\n\tkiosk: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n}\nexport interface NewOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NewArguments\n\t\t| [kiosk: RawTransactionArgument<string>, cap: RawTransactionArgument<string>];\n}\n/**\n * Wrap the KioskOwnerCap making the Kiosk \"owned\" and non-transferable. The\n * `PersonalKioskCap` is returned to allow chaining within a PTB, but the value\n * must be consumed by the `transfer_to_sender` call in any case.\n */\nexport function _new(options: NewOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['kiosk', 'cap'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'new',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface CreateForArguments {\n\tkiosk: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n\trecipient: RawTransactionArgument<string>;\n}\nexport interface CreateForOptions {\n\tpackage?: string;\n\targuments:\n\t\t| CreateForArguments\n\t\t| [\n\t\t\t\tkiosk: RawTransactionArgument<string>,\n\t\t\t\tcap: RawTransactionArgument<string>,\n\t\t\t\trecipient: RawTransactionArgument<string>,\n\t\t ];\n}\n/**\n * Create a `PersonalKiosk` for `recipient`. This is useful when (e.g.) an admin\n * account wants to mint an asset with royalty enforcement on behalf of a user.\n */\nexport function createFor(options: CreateForOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null, 'address'] satisfies (string | null)[];\n\tconst parameterNames = ['kiosk', 'cap', 'recipient'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'create_for',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface BorrowArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface BorrowOptions {\n\tpackage?: string;\n\targuments: BorrowArguments | [self: RawTransactionArgument<string>];\n}\n/** Borrow the `KioskOwnerCap` from the `PersonalKioskCap` object. */\nexport function borrow(options: BorrowOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'borrow',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface BorrowMutArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface BorrowMutOptions {\n\tpackage?: string;\n\targuments: BorrowMutArguments | [self: RawTransactionArgument<string>];\n}\n/** Mutably borrow the `KioskOwnerCap` from the `PersonalKioskCap` object. */\nexport function borrowMut(options: BorrowMutOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'borrow_mut',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface BorrowValArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface BorrowValOptions {\n\tpackage?: string;\n\targuments: BorrowValArguments | [self: RawTransactionArgument<string>];\n}\n/**\n * Borrow the `KioskOwnerCap` from the `PersonalKioskCap` object; `Borrow`\n * hot-potato makes sure that the Cap is returned via `return_val` call.\n */\nexport function borrowVal(options: BorrowValOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'borrow_val',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface ReturnValArguments {\n\tself: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n\tborrow: RawTransactionArgument<string>;\n}\nexport interface ReturnValOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ReturnValArguments\n\t\t| [\n\t\t\t\tself: RawTransactionArgument<string>,\n\t\t\t\tcap: RawTransactionArgument<string>,\n\t\t\t\tborrow: RawTransactionArgument<string>,\n\t\t ];\n}\n/** Return the Cap to the PersonalKioskCap object. */\nexport function returnVal(options: ReturnValOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null, null] satisfies (string | null)[];\n\tconst parameterNames = ['self', 'cap', 'borrow'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'return_val',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface IsPersonalArguments {\n\tkiosk: RawTransactionArgument<string>;\n}\nexport interface IsPersonalOptions {\n\tpackage?: string;\n\targuments: IsPersonalArguments | [kiosk: RawTransactionArgument<string>];\n}\n/** Check if the Kiosk is \"personal\". */\nexport function isPersonal(options: IsPersonalOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['kiosk'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'is_personal',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface OwnerArguments {\n\tkiosk: RawTransactionArgument<string>;\n}\nexport interface OwnerOptions {\n\tpackage?: string;\n\targuments: OwnerArguments | [kiosk: RawTransactionArgument<string>];\n}\n/** Get the owner of the Kiosk if the Kiosk is \"personal\". Aborts otherwise. */\nexport function owner(options: OwnerOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['kiosk'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'owner',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface TryOwnerArguments {\n\tkiosk: RawTransactionArgument<string>;\n}\nexport interface TryOwnerOptions {\n\tpackage?: string;\n\targuments: TryOwnerArguments | [kiosk: RawTransactionArgument<string>];\n}\n/**\n * Try to get the owner of the Kiosk if the Kiosk is \"personal\". Returns None\n * otherwise.\n */\nexport function tryOwner(options: TryOwnerOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['kiosk'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'try_owner',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface TransferToSenderArguments {\n\tself: RawTransactionArgument<string>;\n}\nexport interface TransferToSenderOptions {\n\tpackage?: string;\n\targuments: TransferToSenderArguments | [self: RawTransactionArgument<string>];\n}\n/** Transfer the `PersonalKioskCap` to the transaction sender. */\nexport function transferToSender(options: TransferToSenderOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null] satisfies (string | null)[];\n\tconst parameterNames = ['self'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk',\n\t\t\tfunction: 'transfer_to_sender',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAM,cAAc;AACpB,MAAa,mBAAmB,IAAI,WAAW;CAC9C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,IAAI,IAAI;EACR,KAAK,IAAI,OAAOA,cAAoB;EACpC;CACD,CAAC;AACF,MAAa,SAAS,IAAI,WAAW;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,QAAQ,IAAI;EACZ,UAAU,IAAI;EACd;CACD,CAAC;AACF,MAAa,cAAc,IAAI,WAAW;CACzC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,MAAM,EACvB;CACD,CAAC;AACF,MAAa,mBAAmB,IAAI,WAAW;CAC9C,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,UAAU,IAAI,SACd;CACD,CAAC;;;;;;AAuCF,SAAgB,KAAK,SAAqB;CACzC,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,MAAM,KAAK;CACnC,MAAM,iBAAiB,CAAC,SAAS,MAAM;AACvC,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC;;;;;;AAoFJ,SAAgB,UAAU,SAA2B;CACpD,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,KAAK;CAC7B,MAAM,iBAAiB,CAAC,OAAO;AAC/B,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC;;;AAkBJ,SAAgB,UAAU,SAA2B;CACpD,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB;EAAC;EAAM;EAAM;EAAK;CACzC,MAAM,iBAAiB;EAAC;EAAQ;EAAO;EAAS;AAChD,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC;;;AAyEJ,SAAgB,iBAAiB,SAAkC;CAClE,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,KAAK;CAC7B,MAAM,iBAAiB,CAAC,OAAO;AAC/B,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+
4
+ //#region src/contracts/kiosk/personal_kiosk_rule.ts
5
+ /**************************************************************
6
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
+ **************************************************************/
8
+ /**
9
+ * Description: This module defines a Rule which checks that the Kiosk is
10
+ * "personal" meaning that the owner cannot change. By default, `KioskOwnerCap` can
11
+ * be transferred and owned by an application therefore the owner of the Kiosk is
12
+ * not fixed.
13
+ *
14
+ * Configuration:
15
+ *
16
+ * - None
17
+ *
18
+ * Use cases:
19
+ *
20
+ * - Strong royalty enforcement - personal Kiosks cannot be transferred with the
21
+ * assets inside which means that the item will never change the owner.
22
+ *
23
+ * Notes:
24
+ *
25
+ * - Combination of `kiosk_lock_rule` and `personal_kiosk_rule` can be used to
26
+ * enforce policies on every trade (item can be transferred only through a
27
+ * trade + Kiosk is fixed to the owner).
28
+ */
29
+ const $moduleName = "@local-pkg/kiosk::personal_kiosk_rule";
30
+ const Rule = new MoveStruct({
31
+ name: `${$moduleName}::Rule`,
32
+ fields: { dummy_field: bcs.bool() }
33
+ });
34
+ /** Add the "owned" rule to the KioskOwnerCap. */
35
+ function add(options) {
36
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
37
+ const argumentsTypes = [null, null];
38
+ const parameterNames = ["policy", "cap"];
39
+ return (tx) => tx.moveCall({
40
+ package: packageAddress,
41
+ module: "personal_kiosk_rule",
42
+ function: "add",
43
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
44
+ typeArguments: options.typeArguments
45
+ });
46
+ }
47
+ /**
48
+ * Make sure that the destination Kiosk has the Owner key. Item is already placed
49
+ * by the time this check is performed - otherwise fails.
50
+ */
51
+ function prove(options) {
52
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
53
+ const argumentsTypes = [null, null];
54
+ const parameterNames = ["kiosk", "request"];
55
+ return (tx) => tx.moveCall({
56
+ package: packageAddress,
57
+ module: "personal_kiosk_rule",
58
+ function: "prove",
59
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
60
+ typeArguments: options.typeArguments
61
+ });
62
+ }
63
+
64
+ //#endregion
65
+ export { add, prove };
66
+ //# sourceMappingURL=personal_kiosk_rule.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"personal_kiosk_rule.mjs","names":[],"sources":["../../../src/contracts/kiosk/personal_kiosk_rule.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Description: This module defines a Rule which checks that the Kiosk is\n * \"personal\" meaning that the owner cannot change. By default, `KioskOwnerCap` can\n * be transferred and owned by an application therefore the owner of the Kiosk is\n * not fixed.\n *\n * Configuration:\n *\n * - None\n *\n * Use cases:\n *\n * - Strong royalty enforcement - personal Kiosks cannot be transferred with the\n * assets inside which means that the item will never change the owner.\n *\n * Notes:\n *\n * - Combination of `kiosk_lock_rule` and `personal_kiosk_rule` can be used to\n * enforce policies on every trade (item can be transferred only through a\n * trade + Kiosk is fixed to the owner).\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nconst $moduleName = '@local-pkg/kiosk::personal_kiosk_rule';\nexport const Rule = new MoveStruct({\n\tname: `${$moduleName}::Rule`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport interface AddArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n}\nexport interface AddOptions {\n\tpackage?: string;\n\targuments:\n\t\t| AddArguments\n\t\t| [policy: RawTransactionArgument<string>, cap: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/** Add the \"owned\" rule to the KioskOwnerCap. */\nexport function add(options: AddOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'cap'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk_rule',\n\t\t\tfunction: 'add',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface ProveArguments {\n\tkiosk: RawTransactionArgument<string>;\n\trequest: RawTransactionArgument<string>;\n}\nexport interface ProveOptions {\n\tpackage?: string;\n\targuments:\n\t\t| ProveArguments\n\t\t| [kiosk: RawTransactionArgument<string>, request: RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\n/**\n * Make sure that the destination Kiosk has the Owner key. Item is already placed\n * by the time this check is performed - otherwise fails.\n */\nexport function prove(options: ProveOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null] satisfies (string | null)[];\n\tconst parameterNames = ['kiosk', 'request'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'personal_kiosk_rule',\n\t\t\tfunction: 'prove',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,cAAc;AACpB,MAAa,OAAO,IAAI,WAAW;CAClC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,MAAM,EACvB;CACD,CAAC;;AAaF,SAAgB,IAAI,SAAqB;CACxC,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,MAAM,KAAK;CACnC,MAAM,iBAAiB,CAAC,UAAU,MAAM;AACxC,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC;;;;;;AAiBJ,SAAgB,MAAM,SAAuB;CAC5C,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,MAAM,KAAK;CACnC,MAAM,iBAAiB,CAAC,SAAS,UAAU;AAC3C,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+
4
+ //#region src/contracts/kiosk/royalty_rule.ts
5
+ /**************************************************************
6
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
+ **************************************************************/
8
+ /**
9
+ * Description: This module defines a Rule which requires a payment on a purchase.
10
+ * The payment amount can be either a fixed amount (min_amount) or a percentage of
11
+ * the purchase price (amount_bp). Or both: the higher of the two is used.
12
+ *
13
+ * Configuration:
14
+ *
15
+ * - amount_bp - the percentage of the purchase price to be paid as a fee,
16
+ * denominated in basis points (100_00 = 100%, 1 = 0.01%).
17
+ * - min_amount - the minimum amount to be paid as a fee if the relative amount is
18
+ * lower than this setting.
19
+ *
20
+ * Use cases:
21
+ *
22
+ * - Percentage-based Royalty fee for the creator of the NFT.
23
+ * - Fixed commission fee on a trade.
24
+ * - A mix of both: the higher of the two is used.
25
+ *
26
+ * Notes:
27
+ *
28
+ * - To use it as a fixed commission set the `amount_bp` to 0 and use the
29
+ * `min_amount` to set the fixed amount.
30
+ * - To use it as a percentage-based fee set the `min_amount` to 0 and use the
31
+ * `amount_bp` to set the percentage.
32
+ * - To use it as a mix of both set the `min_amount` to the min amount acceptable
33
+ * and the `amount_bp` to the percentage of the purchase price. The higher of the
34
+ * two will be used.
35
+ */
36
+ const $moduleName = "@local-pkg/kiosk::royalty_rule";
37
+ const Rule = new MoveStruct({
38
+ name: `${$moduleName}::Rule`,
39
+ fields: { dummy_field: bcs.bool() }
40
+ });
41
+ const Config = new MoveStruct({
42
+ name: `${$moduleName}::Config`,
43
+ fields: {
44
+ amount_bp: bcs.u16(),
45
+ min_amount: bcs.u64()
46
+ }
47
+ });
48
+ /**
49
+ * Creator action: Add the Royalty Rule for the `T`. Pass in the `TransferPolicy`,
50
+ * `TransferPolicyCap` and the configuration for the policy: `amount_bp` and
51
+ * `min_amount`.
52
+ */
53
+ function add(options) {
54
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
55
+ const argumentsTypes = [
56
+ null,
57
+ null,
58
+ "u16",
59
+ "u64"
60
+ ];
61
+ const parameterNames = [
62
+ "policy",
63
+ "cap",
64
+ "amountBp",
65
+ "minAmount"
66
+ ];
67
+ return (tx) => tx.moveCall({
68
+ package: packageAddress,
69
+ module: "royalty_rule",
70
+ function: "add",
71
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
72
+ typeArguments: options.typeArguments
73
+ });
74
+ }
75
+ /** Buyer action: Pay the royalty fee for the transfer. */
76
+ function pay(options) {
77
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
78
+ const argumentsTypes = [
79
+ null,
80
+ null,
81
+ null
82
+ ];
83
+ const parameterNames = [
84
+ "policy",
85
+ "request",
86
+ "payment"
87
+ ];
88
+ return (tx) => tx.moveCall({
89
+ package: packageAddress,
90
+ module: "royalty_rule",
91
+ function: "pay",
92
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
93
+ typeArguments: options.typeArguments
94
+ });
95
+ }
96
+ /**
97
+ * Helper function to calculate the amount to be paid for the transfer. Can be used
98
+ * dry-runned to estimate the fee amount based on the Kiosk listing price.
99
+ */
100
+ function feeAmount(options) {
101
+ const packageAddress = options.package ?? "@local-pkg/kiosk";
102
+ const argumentsTypes = [null, "u64"];
103
+ const parameterNames = ["policy", "paid"];
104
+ return (tx) => tx.moveCall({
105
+ package: packageAddress,
106
+ module: "royalty_rule",
107
+ function: "fee_amount",
108
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
109
+ typeArguments: options.typeArguments
110
+ });
111
+ }
112
+
113
+ //#endregion
114
+ export { add, feeAmount, pay };
115
+ //# sourceMappingURL=royalty_rule.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"royalty_rule.mjs","names":[],"sources":["../../../src/contracts/kiosk/royalty_rule.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Description: This module defines a Rule which requires a payment on a purchase.\n * The payment amount can be either a fixed amount (min_amount) or a percentage of\n * the purchase price (amount_bp). Or both: the higher of the two is used.\n *\n * Configuration:\n *\n * - amount_bp - the percentage of the purchase price to be paid as a fee,\n * denominated in basis points (100_00 = 100%, 1 = 0.01%).\n * - min_amount - the minimum amount to be paid as a fee if the relative amount is\n * lower than this setting.\n *\n * Use cases:\n *\n * - Percentage-based Royalty fee for the creator of the NFT.\n * - Fixed commission fee on a trade.\n * - A mix of both: the higher of the two is used.\n *\n * Notes:\n *\n * - To use it as a fixed commission set the `amount_bp` to 0 and use the\n * `min_amount` to set the fixed amount.\n * - To use it as a percentage-based fee set the `min_amount` to 0 and use the\n * `amount_bp` to set the percentage.\n * - To use it as a mix of both set the `min_amount` to the min amount acceptable\n * and the `amount_bp` to the percentage of the purchase price. The higher of the\n * two will be used.\n */\n\nimport { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nconst $moduleName = '@local-pkg/kiosk::royalty_rule';\nexport const Rule = new MoveStruct({\n\tname: `${$moduleName}::Rule`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const Config = new MoveStruct({\n\tname: `${$moduleName}::Config`,\n\tfields: {\n\t\tamount_bp: bcs.u16(),\n\t\tmin_amount: bcs.u64(),\n\t},\n});\nexport interface AddArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tcap: RawTransactionArgument<string>;\n\tamountBp: RawTransactionArgument<number>;\n\tminAmount: RawTransactionArgument<number | bigint>;\n}\nexport interface AddOptions {\n\tpackage?: string;\n\targuments:\n\t\t| AddArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\tcap: RawTransactionArgument<string>,\n\t\t\t\tamountBp: RawTransactionArgument<number>,\n\t\t\t\tminAmount: RawTransactionArgument<number | bigint>,\n\t\t ];\n\ttypeArguments: [string];\n}\n/**\n * Creator action: Add the Royalty Rule for the `T`. Pass in the `TransferPolicy`,\n * `TransferPolicyCap` and the configuration for the policy: `amount_bp` and\n * `min_amount`.\n */\nexport function add(options: AddOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null, 'u16', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'cap', 'amountBp', 'minAmount'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'royalty_rule',\n\t\t\tfunction: 'add',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface PayArguments {\n\tpolicy: RawTransactionArgument<string>;\n\trequest: RawTransactionArgument<string>;\n\tpayment: RawTransactionArgument<string>;\n}\nexport interface PayOptions {\n\tpackage?: string;\n\targuments:\n\t\t| PayArguments\n\t\t| [\n\t\t\t\tpolicy: RawTransactionArgument<string>,\n\t\t\t\trequest: RawTransactionArgument<string>,\n\t\t\t\tpayment: RawTransactionArgument<string>,\n\t\t ];\n\ttypeArguments: [string];\n}\n/** Buyer action: Pay the royalty fee for the transfer. */\nexport function pay(options: PayOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, null, null] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'request', 'payment'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'royalty_rule',\n\t\t\tfunction: 'pay',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface FeeAmountArguments {\n\tpolicy: RawTransactionArgument<string>;\n\tpaid: RawTransactionArgument<number | bigint>;\n}\nexport interface FeeAmountOptions {\n\tpackage?: string;\n\targuments:\n\t\t| FeeAmountArguments\n\t\t| [policy: RawTransactionArgument<string>, paid: RawTransactionArgument<number | bigint>];\n\ttypeArguments: [string];\n}\n/**\n * Helper function to calculate the amount to be paid for the transfer. Can be used\n * dry-runned to estimate the fee amount based on the Kiosk listing price.\n */\nexport function feeAmount(options: FeeAmountOptions) {\n\tconst packageAddress = options.package ?? '@local-pkg/kiosk';\n\tconst argumentsTypes = [null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['policy', 'paid'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'royalty_rule',\n\t\t\tfunction: 'fee_amount',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,cAAc;AACpB,MAAa,OAAO,IAAI,WAAW;CAClC,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,MAAM,EACvB;CACD,CAAC;AACF,MAAa,SAAS,IAAI,WAAW;CACpC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,WAAW,IAAI,KAAK;EACpB,YAAY,IAAI,KAAK;EACrB;CACD,CAAC;;;;;;AAwBF,SAAgB,IAAI,SAAqB;CACxC,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB;EAAC;EAAM;EAAM;EAAO;EAAM;CACjD,MAAM,iBAAiB;EAAC;EAAU;EAAO;EAAY;EAAY;AACjE,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC;;;AAmBJ,SAAgB,IAAI,SAAqB;CACxC,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB;EAAC;EAAM;EAAM;EAAK;CACzC,MAAM,iBAAiB;EAAC;EAAU;EAAW;EAAU;AACvD,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC;;;;;;AAiBJ,SAAgB,UAAU,SAA2B;CACpD,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,MAAM,iBAAiB,CAAC,MAAM,MAAM;CACpC,MAAM,iBAAiB,CAAC,UAAU,OAAO;AACzC,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,eAAe,QAAQ;EACvB,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { BcsStruct, TypeTagSerializer, bcs } from "@mysten/sui/bcs";
2
+ import { normalizeSuiAddress } from "@mysten/sui/utils";
3
+ import { isArgument } from "@mysten/sui/transactions";
4
+
5
+ //#region src/contracts/utils/index.ts
6
+ const MOVE_STDLIB_ADDRESS = normalizeSuiAddress("0x1");
7
+ const SUI_FRAMEWORK_ADDRESS$1 = normalizeSuiAddress("0x2");
8
+ function getPureBcsSchema(typeTag) {
9
+ const parsedTag = typeof typeTag === "string" ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
10
+ if ("u8" in parsedTag) return bcs.U8;
11
+ else if ("u16" in parsedTag) return bcs.U16;
12
+ else if ("u32" in parsedTag) return bcs.U32;
13
+ else if ("u64" in parsedTag) return bcs.U64;
14
+ else if ("u128" in parsedTag) return bcs.U128;
15
+ else if ("u256" in parsedTag) return bcs.U256;
16
+ else if ("address" in parsedTag) return bcs.Address;
17
+ else if ("bool" in parsedTag) return bcs.Bool;
18
+ else if ("vector" in parsedTag) {
19
+ const type = getPureBcsSchema(parsedTag.vector);
20
+ return type ? bcs.vector(type) : null;
21
+ } else if ("struct" in parsedTag) {
22
+ const structTag = parsedTag.struct;
23
+ const pkg = normalizeSuiAddress(structTag.address);
24
+ if (pkg === MOVE_STDLIB_ADDRESS) {
25
+ if ((structTag.module === "ascii" || structTag.module === "string") && structTag.name === "String") return bcs.String;
26
+ if (structTag.module === "option" && structTag.name === "Option") {
27
+ const type = getPureBcsSchema(structTag.typeParams[0]);
28
+ return type ? bcs.option(type) : null;
29
+ }
30
+ }
31
+ if (pkg === SUI_FRAMEWORK_ADDRESS$1 && structTag.module === "object" && (structTag.name === "ID" || structTag.name === "UID")) return bcs.Address;
32
+ }
33
+ return null;
34
+ }
35
+ function normalizeMoveArguments(args, argTypes, parameterNames) {
36
+ const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
37
+ if (parameterNames && argLen !== parameterNames.length) throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
38
+ const normalizedArgs = [];
39
+ let index = 0;
40
+ for (const [i, argType] of argTypes.entries()) {
41
+ if (argType === "0x2::clock::Clock") {
42
+ normalizedArgs.push((tx) => tx.object.clock());
43
+ continue;
44
+ }
45
+ if (argType === "0x2::random::Random") {
46
+ normalizedArgs.push((tx) => tx.object.random());
47
+ continue;
48
+ }
49
+ if (argType === "0x2::deny_list::DenyList") {
50
+ normalizedArgs.push((tx) => tx.object.denyList());
51
+ continue;
52
+ }
53
+ if (argType === "0x3::sui_system::SuiSystemState") {
54
+ normalizedArgs.push((tx) => tx.object.system());
55
+ continue;
56
+ }
57
+ let arg;
58
+ if (Array.isArray(args)) {
59
+ if (index >= args.length) throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
60
+ arg = args[index];
61
+ } else {
62
+ if (!parameterNames) throw new Error(`Expected arguments to be passed as an array`);
63
+ const name = parameterNames[index];
64
+ arg = args[name];
65
+ if (arg === void 0) throw new Error(`Parameter ${name} is required`);
66
+ }
67
+ index += 1;
68
+ if (typeof arg === "function" || isArgument(arg)) {
69
+ normalizedArgs.push(arg);
70
+ continue;
71
+ }
72
+ const type = argTypes[i];
73
+ const bcsType = type === null ? null : getPureBcsSchema(type);
74
+ if (bcsType) {
75
+ const bytes = bcsType.serialize(arg);
76
+ normalizedArgs.push((tx) => tx.pure(bytes));
77
+ continue;
78
+ } else if (typeof arg === "string") {
79
+ normalizedArgs.push((tx) => tx.object(arg));
80
+ continue;
81
+ }
82
+ throw new Error(`Invalid argument ${stringify(arg)} for type ${type}`);
83
+ }
84
+ return normalizedArgs;
85
+ }
86
+ var MoveStruct = class extends BcsStruct {
87
+ async get({ objectId, ...options }) {
88
+ const [res] = await this.getMany({
89
+ ...options,
90
+ objectIds: [objectId]
91
+ });
92
+ return res;
93
+ }
94
+ async getMany({ client, ...options }) {
95
+ return (await client.core.getObjects({
96
+ ...options,
97
+ include: {
98
+ ...options.include,
99
+ content: true
100
+ }
101
+ })).objects.map((obj) => {
102
+ if (obj instanceof Error) throw obj;
103
+ return {
104
+ ...obj,
105
+ json: this.parse(obj.content)
106
+ };
107
+ });
108
+ }
109
+ };
110
+ function stringify(val) {
111
+ if (typeof val === "object") return JSON.stringify(val, (val$1) => val$1);
112
+ if (typeof val === "bigint") return val.toString();
113
+ return val;
114
+ }
115
+
116
+ //#endregion
117
+ export { MoveStruct, normalizeMoveArguments };
118
+ //# sourceMappingURL=index.mjs.map