@haneullabs/kiosk 1.1.2 → 1.1.3

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 (38) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -1
  3. package/dist/client/kiosk-client.d.mts.map +1 -1
  4. package/dist/client/kiosk-transaction.d.mts +1 -2
  5. package/dist/client/kiosk-transaction.d.mts.map +1 -1
  6. package/dist/client/tp-transaction.d.mts +1 -2
  7. package/dist/client/tp-transaction.d.mts.map +1 -1
  8. package/dist/constants.d.mts.map +1 -1
  9. package/dist/contracts/kiosk/deps/haneul/kiosk.mjs +1 -1
  10. package/dist/contracts/kiosk/deps/haneul/kiosk.mjs.map +1 -1
  11. package/dist/query/client-utils.mjs +6 -6
  12. package/dist/query/client-utils.mjs.map +1 -1
  13. package/dist/types/index.d.mts +0 -1
  14. package/dist/types/index.d.mts.map +1 -1
  15. package/dist/types/kiosk.d.mts +13 -27
  16. package/dist/types/kiosk.d.mts.map +1 -1
  17. package/dist/types/kiosk.mjs.map +1 -1
  18. package/dist/types/transfer-policy.d.mts.map +1 -1
  19. package/dist/utils.d.mts +1 -1
  20. package/dist/utils.d.mts.map +1 -1
  21. package/dist/utils.mjs.map +1 -1
  22. package/docs/advanced-examples.md +100 -0
  23. package/docs/from-v1.md +314 -0
  24. package/docs/index.md +22 -0
  25. package/docs/kiosk-client/introduction.md +50 -0
  26. package/docs/kiosk-client/kiosk-transaction/examples.md +119 -0
  27. package/docs/kiosk-client/kiosk-transaction/kiosk-transaction.md +103 -0
  28. package/docs/kiosk-client/kiosk-transaction/managing.md +235 -0
  29. package/docs/kiosk-client/kiosk-transaction/purchasing.md +110 -0
  30. package/docs/kiosk-client/querying.md +237 -0
  31. package/docs/kiosk-client/transfer-policy-transaction/introduction.md +79 -0
  32. package/docs/kiosk-client/transfer-policy-transaction/using-the-manager.md +115 -0
  33. package/docs/llms-index.md +10 -0
  34. package/package.json +8 -6
  35. package/src/contracts/kiosk/deps/haneul/kiosk.ts +1 -1
  36. package/src/query/client-utils.ts +6 -6
  37. package/src/types/kiosk.ts +7 -4
  38. package/src/utils.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @mysten/kiosk
2
2
 
3
+ ## 1.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 43e69f8: Add embedded LLM-friendly docs to published packages
8
+ - Updated dependencies [43e69f8]
9
+ - Updated dependencies [e51dc5d]
10
+ - @mysten/bcs@2.0.3
11
+ - @mysten/sui@2.8.0
12
+
3
13
  ## 1.1.2
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Kiosk SDK
2
2
 
3
3
  This Kiosk SDK library provides different utilities to interact/create/manage a
4
- [Kiosk](https://github.com/HaneulLabs/haneul/tree/main/kiosk).
4
+ [Kiosk](https://github.com/GeunhwaJeong/haneul/tree/main/kiosk).
5
5
 
6
6
  [You can read the documentation and see examples by clicking here.](https://sdk.haneul-labs.com/kiosk)
7
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"kiosk-client.d.mts","names":[],"sources":["../../src/client/kiosk-client.ts"],"sourcesContent":[],"mappings":";;;;;;;;KA6BY;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,qBA8CN,EAAA,GA9C2B,WA8C3B;CACF;;;;;;;AA2Bc,cA1Dd,WAAA,CA0Dc;EAAS,MAAA,EAzD3B,qBAyD2B;EAAI,OAAA,EAxD9B,iBAAA,CAAkB,OAwDY;EAAqC,KAAA,EAvDrE,kBAuDqE,EAAA;EAQhD,UAAA,CAAA,EA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A;EAQP;;;;EAA1B,mBAAA,CAAA;IAAsB;EAAA;IAAU,IAAA;EAAA,IAAc,OAAA,CAApB,cAAA;EAkBoB;;;;;EAT9C,wBAAA,CAAA;IAA2B;EAAA;IAAa,OAAA;EAAA,IAAiB,OAAA,CAAvB,iBAAA;EAzE/B;;;;;EAkFH,8BAAA,CAAA;IAAiC,IAAA;IAAM;EAAA;IAAa,IAAA;IAAc,OAAA;EAAA,IAAiB,OAAA,CAArC,iBAAA;EAOpD,eAAA,CAAgB,IAAA,EAAM,kBAAA;EAjErB;;;;EA2ED,gBAAA,CACC,IAAA;AAAA"}
@@ -5,8 +5,7 @@ import { Transaction, TransactionArgument, TransactionObjectArgument } from "@ha
5
5
 
6
6
  //#region src/client/kiosk-transaction.d.ts
7
7
  type KioskTransactionParams = {
8
- /** The Transaction for this run */
9
- transaction: Transaction;
8
+ /** The Transaction for this run */transaction: Transaction;
10
9
  /**
11
10
  * You can create a new KioskClient by calling `new KioskClient()`
12
11
  */
@@ -1 +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,CAA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AAA;EA7OlB;;;;;EA8PX,IAAA,CAAA;IAAO,QAAA;IAAU;EAAA,GAAU,MAAA,GAAS,yBAAA;EAlPI;;;;;;;EAoQxC,QAAA,CAAA;IAAW,QAAA;IAAU,MAAA;IAAQ;EAAA,GAAW,MAAA;IAAW,OAAA;EAAA;EA3KnD;;;;;;;EA0LA,IAAA,CAAA;IACC,QAAA;IACA,IAAA;IACA,MAAA;IACA;EAAA,GACE,aAAA;IAAkB,MAAA,EAAQ,cAAA;IAAgB,MAAA;EAAA;EA9JpC;;;;;;;;;EAwLT,QAAA,CAAA;IACC,QAAA;IACA,MAAA;IACA,KAAA;IACA;EAAA,GACE,MAAA,GAAS,KAAA;IAAU,WAAA,EAAa,cAAA;EAAA,KAClC,yBAAA,EACA,yBAAA;EA/KiD;;;;;;;;;;EAwM5C,kBAAA,CAAA;IACL,QAAA;IACA,MAAA;IACA,KAAA;IACA,WAAA;IACA;EAAA,GACE,MAAA,GAAS,KAAA;IAAU,WAAA,EAAa,cAAA;EAAA,IAAmB,eAAA,GAAe,OAAA;EA3JtD;;;;;EA4Nf,MAAA,CAAO,GAAA,EAAK,aAAA;EA5N4C;;;;;EA4OxD,QAAA,CAAA;EAgDA,WAAA,CAAY,GAAA,EAAK,yBAAA;EAMjB,QAAA,CAAS,KAAA,EAAO,yBAAA;EAUhB,QAAA,CAAA,GAAQ,yBAAA;EASR,WAAA,CAAA,GAAW,yBAAA;AAAA"}
@@ -92,8 +92,7 @@ declare class TransferPolicyTransaction {
92
92
  * @param percentageBps The royalty percentage in basis points. Use `percentageToBasisPoints` helper to convert from percentage [0,100].
93
93
  * @param minAmount The minimum royalty amount per request in GEUNHWA.
94
94
  */
95
- addRoyaltyRule(percentageBps: number | string,
96
- // this is in basis points.
95
+ addRoyaltyRule(percentageBps: number | string, // this is in basis points.
97
96
  minAmount: number | string): this;
98
97
  /**
99
98
  * Adds the Kiosk Lock Rule to the Transfer Policy.
@@ -1 +1 @@
1
- {"version":3,"file":"tp-transaction.d.mts","names":[],"sources":["../../src/client/tp-transaction.ts"],"sourcesContent":[],"mappings":";;;;;;KAcY,wBAAA;;aAEA;EAFA,SAAA,CAAA,EAAA,OAAA;AAMZ,CAAA;AACc,KADF,+BAAA,GACE;EACA,WAAA,EADA,WACA;EACP,WAAA,EADO,WACP;EAAiB,GAAA,CAAA,EAAjB,iBAAiB;AAGxB,CAAA;AACc,cADD,yBAAA,CACC;EACA,CAAA,OAAA;EACJ,WAAA,EAFI,WAEJ;EACG,WAAA,EAFC,WAED;EAGE,MAAA,CAAA,EAJL,cAIK;EAAa,SAAA,CAAA,EAHf,cAGe;EAAa,IAAA,CAAA,EAAA,MAAA;EAAO,WAAA,CAAA;IAAA,WAAA;IAAA,WAAA;IAAA;EAAA,CAAA,EAAA,+BAAA;EAmB9C;;;;;;;;;;;;EA6EQ,cAAA,CAAA;IAAA,IAAA;IAAA,SAAA;IAAA,OAAA;IAAA;EAAuB,CAAvB,EAzEN,wBAyEM,GAAA;IAAU,OAAA,EAAA,MAAA;EAAa,CAAA,CAAA,EAvE/B,OAuE+B,CAAA,IAAA,CAAA;EAAQ;;;;;;;;;;;;KAlDrC,2BAA2B,QAAQ;;;;;;;;;;;;;;;;;KAkDE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA0P/B;kBAKG"}
1
+ {"version":3,"file":"tp-transaction.d.mts","names":[],"sources":["../../src/client/tp-transaction.ts"],"mappings":";;;;;;KAcY,wBAAA;EACX,IAAA;EACA,SAAA,EAAW,cAAA;EACX,SAAA;AAAA;AAAA,KAGW,+BAAA;EACX,WAAA,EAAa,WAAA;EACb,WAAA,EAAa,WAAA;EACb,GAAA,GAAM,iBAAA;AAAA;AAAA,cAGM,yBAAA;EAAA;EACZ,WAAA,EAAa,WAAA;EACb,WAAA,EAAa,WAAA;EACb,MAAA,GAAS,cAAA;EACT,SAAA,GAAY,cAAA;EACZ,IAAA;;IAEc,WAAA;IAAa,WAAA;IAA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CAAO,iBAAA,CAAkB,OAAA;AAAA,cAK3D,2BAAA,EAA6B,OAAA,CAAQ,MAAA,CAAO,iBAAA,CAAkB,OAAA;;;;iBAQ3D,YAAA,CAAA;EACf,oBAAA;EACA,sBAAA;EACA,0BAAA;EACA;AAAA,GACE,kBAAA,GAAqB,kBAAA;AAAA,cAwCX,YAAA,EAAc,kBAAA;AAAA,cAQd,YAAA,EAAc,kBAAA;AAAA,cAKd,KAAA,EAAO,kBAAA"}
@@ -34,7 +34,7 @@ import { bcs } from "@haneullabs/haneul/bcs";
34
34
  *
35
35
  * - `locked` - Similar to `placed` except that `take` is disabled and the only way
36
36
  * to move the asset out of the Kiosk is to `list` it or `list_with_purchase_cap`
37
- * therefore performing a trade (issuing a `TransferRequest`). The check on the
37
+ * therefore performing a trade (ishaneulng a `TransferRequest`). The check on the
38
38
  * `lock` function makes sure that the `TransferPolicy` exists to not lock the
39
39
  * item in a `Kiosk` forever.
40
40
  *
@@ -1 +1 @@
1
- {"version":3,"file":"kiosk.mjs","names":[],"sources":["../../../../../src/contracts/kiosk/deps/haneul/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 HANEUL 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 '@haneullabs/haneul/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"}
1
+ {"version":3,"file":"kiosk.mjs","names":[],"sources":["../../../../../src/contracts/kiosk/deps/haneul/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 (ishaneulng 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 HANEUL 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 '@haneullabs/haneul/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"}
@@ -1,7 +1,7 @@
1
1
  import { normalizeStructTag } from "@haneullabs/haneul/utils";
2
2
  import { graphql } from "@haneullabs/haneul/graphql/schema";
3
- import { isSuiGraphQLClient } from "@haneullabs/haneul/graphql";
4
- import { isSuiJsonRpcClient } from "@haneullabs/haneul/jsonRpc";
3
+ import { isHaneulGraphQLClient } from "@haneullabs/haneul/graphql";
4
+ import { isHaneulJsonRpcClient } from "@haneullabs/haneul/jsonRpc";
5
5
  import { chunk, fromBase64 } from "@haneullabs/utils";
6
6
 
7
7
  //#region src/query/client-utils.ts
@@ -59,7 +59,7 @@ async function getAllObjects(client, ids) {
59
59
  if (ids.length === 0) return [];
60
60
  const chunks = chunk(ids, DEFAULT_QUERY_LIMIT);
61
61
  const results = [];
62
- if (isSuiGraphQLClient(client)) {
62
+ if (isHaneulGraphQLClient(client)) {
63
63
  for (const batch of chunks) {
64
64
  const { data } = await client.query({
65
65
  query: FetchObjectsWithDisplayQuery,
@@ -93,7 +93,7 @@ async function getAllObjects(client, ids) {
93
93
  }
94
94
  return results;
95
95
  }
96
- if (isSuiJsonRpcClient(client)) {
96
+ if (isHaneulJsonRpcClient(client)) {
97
97
  for (const batch of chunks) {
98
98
  const responses = await client.multiGetObjects({
99
99
  ids: batch,
@@ -189,7 +189,7 @@ function mapGraphQLOwner(owner) {
189
189
  }
190
190
  }
191
191
  async function queryEvents(client, eventType) {
192
- if (isSuiGraphQLClient(client)) {
192
+ if (isHaneulGraphQLClient(client)) {
193
193
  const query = graphql(`
194
194
  query QueryEvents($eventType: String!) {
195
195
  events(filter: { eventType: $eventType }, first: 50) {
@@ -206,7 +206,7 @@ async function queryEvents(client, eventType) {
206
206
  variables: { eventType }
207
207
  })).data?.events?.nodes.map((event) => ({ json: event.contents?.json })) ?? [];
208
208
  }
209
- if (isSuiJsonRpcClient(client)) return (await client.queryEvents({ query: { MoveEventType: eventType } })).data?.map((d) => ({ json: d.parsedJson })) ?? [];
209
+ if (isHaneulJsonRpcClient(client)) return (await client.queryEvents({ query: { MoveEventType: eventType } })).data?.map((d) => ({ json: d.parsedJson })) ?? [];
210
210
  throw new Error("Event querying is not supported by this client type. JSON-RPC and GraphQL clients support event querying, but gRPC does not. Please use a JSON-RPC or GraphQL client, or provide the required IDs directly.");
211
211
  }
212
212
 
@@ -1 +1 @@
1
- {"version":3,"file":"client-utils.mjs","names":[],"sources":["../../src/query/client-utils.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { HaneulClientTypes } from '@haneullabs/haneul/client';\nimport { graphql } from '@haneullabs/haneul/graphql/schema';\nimport { isSuiGraphQLClient } from '@haneullabs/haneul/graphql';\nimport { isSuiJsonRpcClient } from '@haneullabs/haneul/jsonRpc';\nimport { normalizeStructTag } from '@haneullabs/haneul/utils';\nimport { chunk, fromBase64 } from '@haneullabs/utils';\n\nimport type { KioskDisplay, ObjectWithDisplay } from '../types/kiosk.js';\nimport type { KioskCompatibleClient } from '../types/index.js';\n\nconst DEFAULT_QUERY_LIMIT = 50;\n\nconst FetchObjectsWithDisplayQuery = graphql(`\n\tquery FetchObjectsWithDisplay($objectKeys: [ObjectKey!]!) {\n\t\tmultiGetObjects(keys: $objectKeys) {\n\t\t\taddress\n\t\t\tdigest\n\t\t\tversion\n\t\t\tasMoveObject {\n\t\t\t\tcontents {\n\t\t\t\t\tbcs\n\t\t\t\t\ttype {\n\t\t\t\t\t\trepr\n\t\t\t\t\t}\n\t\t\t\t\tdisplay {\n\t\t\t\t\t\toutput\n\t\t\t\t\t\terrors\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tasMovePackage {\n\t\t\t\t__typename\n\t\t\t}\n\t\t\towner {\n\t\t\t\t__typename\n\t\t\t\t... on AddressOwner {\n\t\t\t\t\taddress {\n\t\t\t\t\t\taddress\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t... on ObjectOwner {\n\t\t\t\t\taddress {\n\t\t\t\t\t\taddress\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t... on Shared {\n\t\t\t\t\tinitialSharedVersion\n\t\t\t\t}\n\t\t\t\t... on ConsensusAddressOwner {\n\t\t\t\t\tstartVersion\n\t\t\t\t\taddress {\n\t\t\t\t\t\taddress\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tpreviousTransaction {\n\t\t\t\tdigest\n\t\t\t}\n\t\t}\n\t}\n`);\n\nexport async function getAllObjects(\n\tclient: KioskCompatibleClient,\n\tids: string[],\n): Promise<ObjectWithDisplay[]> {\n\tif (ids.length === 0) return [];\n\n\tconst chunks = chunk(ids, DEFAULT_QUERY_LIMIT);\n\tconst results: ObjectWithDisplay[] = [];\n\n\tif (isSuiGraphQLClient(client)) {\n\t\tfor (const batch of chunks) {\n\t\t\tconst { data } = await client.query({\n\t\t\t\tquery: FetchObjectsWithDisplayQuery,\n\t\t\t\tvariables: {\n\t\t\t\t\tobjectKeys: batch.map((address) => ({ address })),\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (data?.multiGetObjects) {\n\t\t\t\tfor (const obj of data.multiGetObjects) {\n\t\t\t\t\tif (!obj) continue;\n\n\t\t\t\t\tlet type: string;\n\t\t\t\t\tif (obj.asMovePackage) {\n\t\t\t\t\t\ttype = 'package';\n\t\t\t\t\t} else if (obj.asMoveObject?.contents?.type?.repr) {\n\t\t\t\t\t\ttype = obj.asMoveObject.contents.type.repr;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttype = '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst bcsContent = obj.asMoveObject?.contents?.bcs\n\t\t\t\t\t\t? fromBase64(obj.asMoveObject.contents.bcs)\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tconst displayData = obj.asMoveObject?.contents?.display;\n\t\t\t\t\tconst display: KioskDisplay | undefined = displayData\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tdata: (displayData.output as Record<string, string> | null) ?? null,\n\t\t\t\t\t\t\t\terror: displayData.errors ? JSON.stringify(displayData.errors) : null,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\tobjectId: obj.address,\n\t\t\t\t\t\tversion: obj.version?.toString()!,\n\t\t\t\t\t\tdigest: obj.digest!,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tcontent: bcsContent!,\n\t\t\t\t\t\towner: mapGraphQLOwner(obj.owner!),\n\t\t\t\t\t\tpreviousTransaction: (obj.previousTransaction?.digest ?? null)!,\n\t\t\t\t\t\tobjectBcs: undefined,\n\t\t\t\t\t\tjson: undefined,\n\t\t\t\t\t\tdisplay,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tif (isSuiJsonRpcClient(client)) {\n\t\tfor (const batch of chunks) {\n\t\t\tconst responses = await client.multiGetObjects({\n\t\t\t\tids: batch,\n\t\t\t\toptions: {\n\t\t\t\t\tshowDisplay: true,\n\t\t\t\t\tshowBcs: true,\n\t\t\t\t\tshowType: true,\n\t\t\t\t\tshowOwner: true,\n\t\t\t\t\tshowPreviousTransaction: true,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tfor (const resp of responses) {\n\t\t\t\tif (!resp.data) continue;\n\t\t\t\tconst obj = resp.data;\n\n\t\t\t\tconst bcsContent =\n\t\t\t\t\tobj.bcs?.dataType === 'moveObject' ? fromBase64(obj.bcs.bcsBytes) : undefined;\n\n\t\t\t\tconst type =\n\t\t\t\t\tobj.type && obj.type.includes('::') ? normalizeStructTag(obj.type) : (obj.type ?? '');\n\n\t\t\t\tconst display: KioskDisplay | undefined = obj.display\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdata: obj.display.data ?? null,\n\t\t\t\t\t\t\terror: obj.display.error ? JSON.stringify(obj.display.error) : null,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined;\n\n\t\t\t\tresults.push({\n\t\t\t\t\tobjectId: obj.objectId,\n\t\t\t\t\tversion: obj.version,\n\t\t\t\t\tdigest: obj.digest,\n\t\t\t\t\ttype,\n\t\t\t\t\tcontent: bcsContent!,\n\t\t\t\t\towner: parseJsonRpcOwner(obj.owner!),\n\t\t\t\t\tpreviousTransaction: (obj.previousTransaction ?? null)!,\n\t\t\t\t\tobjectBcs: undefined,\n\t\t\t\t\tjson: undefined,\n\t\t\t\t\tdisplay,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tthrow new Error(\n\t\t'Object fetching requires a JSON-RPC or GraphQL client. ' +\n\t\t\t'gRPC clients are not supported by the kiosk SDK.',\n\t);\n}\n\nfunction parseJsonRpcOwner(owner: NonNullable<unknown>): HaneulClientTypes.ObjectOwner {\n\tif (owner === 'Immutable') {\n\t\treturn { $kind: 'Immutable', Immutable: true } as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tconst ownerObj = owner as Record<string, any>;\n\n\tif ('ConsensusAddressOwner' in ownerObj) {\n\t\treturn {\n\t\t\t$kind: 'ConsensusAddressOwner',\n\t\t\tConsensusAddressOwner: {\n\t\t\t\towner: ownerObj.ConsensusAddressOwner.owner,\n\t\t\t\tstartVersion: ownerObj.ConsensusAddressOwner.start_version,\n\t\t\t},\n\t\t} as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tif ('AddressOwner' in ownerObj) {\n\t\treturn {\n\t\t\t$kind: 'AddressOwner',\n\t\t\tAddressOwner: ownerObj.AddressOwner,\n\t\t} as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tif ('ObjectOwner' in ownerObj) {\n\t\treturn {\n\t\t\t$kind: 'ObjectOwner',\n\t\t\tObjectOwner: ownerObj.ObjectOwner,\n\t\t} as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tif ('Shared' in ownerObj) {\n\t\treturn {\n\t\t\t$kind: 'Shared',\n\t\t\tShared: {\n\t\t\t\tinitialSharedVersion: ownerObj.Shared.initial_shared_version,\n\t\t\t},\n\t\t} as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tthrow new Error(`Unknown owner type: ${JSON.stringify(owner)}`);\n}\n\nfunction mapGraphQLOwner(\n\towner: NonNullable<unknown> & { __typename?: string },\n): HaneulClientTypes.ObjectOwner {\n\tconst o = owner as Record<string, any>;\n\tswitch (o.__typename) {\n\t\tcase 'AddressOwner':\n\t\t\treturn {\n\t\t\t\t$kind: 'AddressOwner',\n\t\t\t\tAddressOwner: o.address?.address!,\n\t\t\t} as HaneulClientTypes.ObjectOwner;\n\t\tcase 'ObjectOwner':\n\t\t\treturn {\n\t\t\t\t$kind: 'ObjectOwner',\n\t\t\t\tObjectOwner: o.address?.address!,\n\t\t\t} as HaneulClientTypes.ObjectOwner;\n\t\tcase 'Immutable':\n\t\t\treturn { $kind: 'Immutable', Immutable: true } as HaneulClientTypes.ObjectOwner;\n\t\tcase 'Shared':\n\t\t\treturn {\n\t\t\t\t$kind: 'Shared',\n\t\t\t\tShared: { initialSharedVersion: String(o.initialSharedVersion) },\n\t\t\t} as HaneulClientTypes.ObjectOwner;\n\t\tcase 'ConsensusAddressOwner':\n\t\t\treturn {\n\t\t\t\t$kind: 'ConsensusAddressOwner',\n\t\t\t\tConsensusAddressOwner: {\n\t\t\t\t\towner: o.address?.address!,\n\t\t\t\t\tstartVersion: String(o.startVersion),\n\t\t\t\t},\n\t\t\t} as HaneulClientTypes.ObjectOwner;\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown GraphQL owner type: ${o.__typename}`);\n\t}\n}\n\nexport async function queryEvents(\n\tclient: KioskCompatibleClient,\n\teventType: string,\n): Promise<{ json: unknown }[]> {\n\tif (isSuiGraphQLClient(client)) {\n\t\tconst query = graphql(`\n\t\t\tquery QueryEvents($eventType: String!) {\n\t\t\t\tevents(filter: { eventType: $eventType }, first: 50) {\n\t\t\t\t\tnodes {\n\t\t\t\t\t\tcontents {\n\t\t\t\t\t\t\tjson\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t`);\n\n\t\tconst result = await client.query({\n\t\t\tquery,\n\t\t\tvariables: { eventType },\n\t\t});\n\n\t\treturn (\n\t\t\tresult.data?.events?.nodes.map((event) => ({\n\t\t\t\tjson: event.contents?.json,\n\t\t\t})) ?? []\n\t\t);\n\t}\n\n\tif (isSuiJsonRpcClient(client)) {\n\t\tconst events = await client.queryEvents({\n\t\t\tquery: { MoveEventType: eventType },\n\t\t});\n\n\t\treturn events.data?.map((d) => ({ json: d.parsedJson })) ?? [];\n\t}\n\n\tthrow new Error(\n\t\t'Event querying is not supported by this client type. ' +\n\t\t\t'JSON-RPC and GraphQL clients support event querying, but gRPC does not. ' +\n\t\t\t'Please use a JSON-RPC or GraphQL client, or provide the required IDs directly.',\n\t);\n}\n"],"mappings":";;;;;;;AAaA,MAAM,sBAAsB;AAE5B,MAAM,+BAA+B,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O;GACN,OAAO;GACP,cAAc,EAAE,SAAS;GACzB;EACF,KAAK,cACJ,QAAO;GACN,OAAO;GACP,aAAa,EAAE,SAAS;GACxB;EACF,KAAK,YACJ,QAAO;GAAE,OAAO;GAAa,WAAW;GAAM;EAC/C,KAAK,SACJ,QAAO;GACN,OAAO;GACP,QAAQ,EAAE,sBAAsB,OAAO,EAAE,qBAAqB,EAAE;GAChE;EACF,KAAK,wBACJ,QAAO;GACN,OAAO;GACP,uBAAuB;IACtB,OAAO,EAAE,SAAS;IAClB,cAAc,OAAO,EAAE,aAAa;IACpC;GACD;EACF,QACC,OAAM,IAAI,MAAM,+BAA+B,EAAE,aAAa;;;AAIjE,eAAsB,YACrB,QACA,WAC+B;AAC/B,KAAI,mBAAmB,OAAO,EAAE;EAC/B,MAAM,QAAQ,QAAQ;;;;;;;;;;IAUpB;AAOF,UALe,MAAM,OAAO,MAAM;GACjC;GACA,WAAW,EAAE,WAAW;GACxB,CAAC,EAGM,MAAM,QAAQ,MAAM,KAAK,WAAW,EAC1C,MAAM,MAAM,UAAU,MACtB,EAAE,IAAI,EAAE;;AAIX,KAAI,mBAAmB,OAAO,CAK7B,SAJe,MAAM,OAAO,YAAY,EACvC,OAAO,EAAE,eAAe,WAAW,EACnC,CAAC,EAEY,MAAM,KAAK,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE;AAG/D,OAAM,IAAI,MACT,8MAGA"}
1
+ {"version":3,"file":"client-utils.mjs","names":[],"sources":["../../src/query/client-utils.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { HaneulClientTypes } from '@haneullabs/haneul/client';\nimport { graphql } from '@haneullabs/haneul/graphql/schema';\nimport { isHaneulGraphQLClient } from '@haneullabs/haneul/graphql';\nimport { isHaneulJsonRpcClient } from '@haneullabs/haneul/jsonRpc';\nimport { normalizeStructTag } from '@haneullabs/haneul/utils';\nimport { chunk, fromBase64 } from '@haneullabs/utils';\n\nimport type { KioskDisplay, ObjectWithDisplay } from '../types/kiosk.js';\nimport type { KioskCompatibleClient } from '../types/index.js';\n\nconst DEFAULT_QUERY_LIMIT = 50;\n\nconst FetchObjectsWithDisplayQuery = graphql(`\n\tquery FetchObjectsWithDisplay($objectKeys: [ObjectKey!]!) {\n\t\tmultiGetObjects(keys: $objectKeys) {\n\t\t\taddress\n\t\t\tdigest\n\t\t\tversion\n\t\t\tasMoveObject {\n\t\t\t\tcontents {\n\t\t\t\t\tbcs\n\t\t\t\t\ttype {\n\t\t\t\t\t\trepr\n\t\t\t\t\t}\n\t\t\t\t\tdisplay {\n\t\t\t\t\t\toutput\n\t\t\t\t\t\terrors\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tasMovePackage {\n\t\t\t\t__typename\n\t\t\t}\n\t\t\towner {\n\t\t\t\t__typename\n\t\t\t\t... on AddressOwner {\n\t\t\t\t\taddress {\n\t\t\t\t\t\taddress\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t... on ObjectOwner {\n\t\t\t\t\taddress {\n\t\t\t\t\t\taddress\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t... on Shared {\n\t\t\t\t\tinitialSharedVersion\n\t\t\t\t}\n\t\t\t\t... on ConsensusAddressOwner {\n\t\t\t\t\tstartVersion\n\t\t\t\t\taddress {\n\t\t\t\t\t\taddress\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tpreviousTransaction {\n\t\t\t\tdigest\n\t\t\t}\n\t\t}\n\t}\n`);\n\nexport async function getAllObjects(\n\tclient: KioskCompatibleClient,\n\tids: string[],\n): Promise<ObjectWithDisplay[]> {\n\tif (ids.length === 0) return [];\n\n\tconst chunks = chunk(ids, DEFAULT_QUERY_LIMIT);\n\tconst results: ObjectWithDisplay[] = [];\n\n\tif (isHaneulGraphQLClient(client)) {\n\t\tfor (const batch of chunks) {\n\t\t\tconst { data } = await client.query({\n\t\t\t\tquery: FetchObjectsWithDisplayQuery,\n\t\t\t\tvariables: {\n\t\t\t\t\tobjectKeys: batch.map((address) => ({ address })),\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tif (data?.multiGetObjects) {\n\t\t\t\tfor (const obj of data.multiGetObjects) {\n\t\t\t\t\tif (!obj) continue;\n\n\t\t\t\t\tlet type: string;\n\t\t\t\t\tif (obj.asMovePackage) {\n\t\t\t\t\t\ttype = 'package';\n\t\t\t\t\t} else if (obj.asMoveObject?.contents?.type?.repr) {\n\t\t\t\t\t\ttype = obj.asMoveObject.contents.type.repr;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttype = '';\n\t\t\t\t\t}\n\n\t\t\t\t\tconst bcsContent = obj.asMoveObject?.contents?.bcs\n\t\t\t\t\t\t? fromBase64(obj.asMoveObject.contents.bcs)\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tconst displayData = obj.asMoveObject?.contents?.display;\n\t\t\t\t\tconst display: KioskDisplay | undefined = displayData\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tdata: (displayData.output as Record<string, string> | null) ?? null,\n\t\t\t\t\t\t\t\terror: displayData.errors ? JSON.stringify(displayData.errors) : null,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tresults.push({\n\t\t\t\t\t\tobjectId: obj.address,\n\t\t\t\t\t\tversion: obj.version?.toString()!,\n\t\t\t\t\t\tdigest: obj.digest!,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tcontent: bcsContent!,\n\t\t\t\t\t\towner: mapGraphQLOwner(obj.owner!),\n\t\t\t\t\t\tpreviousTransaction: (obj.previousTransaction?.digest ?? null)!,\n\t\t\t\t\t\tobjectBcs: undefined,\n\t\t\t\t\t\tjson: undefined,\n\t\t\t\t\t\tdisplay,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tif (isHaneulJsonRpcClient(client)) {\n\t\tfor (const batch of chunks) {\n\t\t\tconst responses = await client.multiGetObjects({\n\t\t\t\tids: batch,\n\t\t\t\toptions: {\n\t\t\t\t\tshowDisplay: true,\n\t\t\t\t\tshowBcs: true,\n\t\t\t\t\tshowType: true,\n\t\t\t\t\tshowOwner: true,\n\t\t\t\t\tshowPreviousTransaction: true,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tfor (const resp of responses) {\n\t\t\t\tif (!resp.data) continue;\n\t\t\t\tconst obj = resp.data;\n\n\t\t\t\tconst bcsContent =\n\t\t\t\t\tobj.bcs?.dataType === 'moveObject' ? fromBase64(obj.bcs.bcsBytes) : undefined;\n\n\t\t\t\tconst type =\n\t\t\t\t\tobj.type && obj.type.includes('::') ? normalizeStructTag(obj.type) : (obj.type ?? '');\n\n\t\t\t\tconst display: KioskDisplay | undefined = obj.display\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdata: obj.display.data ?? null,\n\t\t\t\t\t\t\terror: obj.display.error ? JSON.stringify(obj.display.error) : null,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined;\n\n\t\t\t\tresults.push({\n\t\t\t\t\tobjectId: obj.objectId,\n\t\t\t\t\tversion: obj.version,\n\t\t\t\t\tdigest: obj.digest,\n\t\t\t\t\ttype,\n\t\t\t\t\tcontent: bcsContent!,\n\t\t\t\t\towner: parseJsonRpcOwner(obj.owner!),\n\t\t\t\t\tpreviousTransaction: (obj.previousTransaction ?? null)!,\n\t\t\t\t\tobjectBcs: undefined,\n\t\t\t\t\tjson: undefined,\n\t\t\t\t\tdisplay,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tthrow new Error(\n\t\t'Object fetching requires a JSON-RPC or GraphQL client. ' +\n\t\t\t'gRPC clients are not supported by the kiosk SDK.',\n\t);\n}\n\nfunction parseJsonRpcOwner(owner: NonNullable<unknown>): HaneulClientTypes.ObjectOwner {\n\tif (owner === 'Immutable') {\n\t\treturn { $kind: 'Immutable', Immutable: true } as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tconst ownerObj = owner as Record<string, any>;\n\n\tif ('ConsensusAddressOwner' in ownerObj) {\n\t\treturn {\n\t\t\t$kind: 'ConsensusAddressOwner',\n\t\t\tConsensusAddressOwner: {\n\t\t\t\towner: ownerObj.ConsensusAddressOwner.owner,\n\t\t\t\tstartVersion: ownerObj.ConsensusAddressOwner.start_version,\n\t\t\t},\n\t\t} as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tif ('AddressOwner' in ownerObj) {\n\t\treturn {\n\t\t\t$kind: 'AddressOwner',\n\t\t\tAddressOwner: ownerObj.AddressOwner,\n\t\t} as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tif ('ObjectOwner' in ownerObj) {\n\t\treturn {\n\t\t\t$kind: 'ObjectOwner',\n\t\t\tObjectOwner: ownerObj.ObjectOwner,\n\t\t} as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tif ('Shared' in ownerObj) {\n\t\treturn {\n\t\t\t$kind: 'Shared',\n\t\t\tShared: {\n\t\t\t\tinitialSharedVersion: ownerObj.Shared.initial_shared_version,\n\t\t\t},\n\t\t} as HaneulClientTypes.ObjectOwner;\n\t}\n\n\tthrow new Error(`Unknown owner type: ${JSON.stringify(owner)}`);\n}\n\nfunction mapGraphQLOwner(\n\towner: NonNullable<unknown> & { __typename?: string },\n): HaneulClientTypes.ObjectOwner {\n\tconst o = owner as Record<string, any>;\n\tswitch (o.__typename) {\n\t\tcase 'AddressOwner':\n\t\t\treturn {\n\t\t\t\t$kind: 'AddressOwner',\n\t\t\t\tAddressOwner: o.address?.address!,\n\t\t\t} as HaneulClientTypes.ObjectOwner;\n\t\tcase 'ObjectOwner':\n\t\t\treturn {\n\t\t\t\t$kind: 'ObjectOwner',\n\t\t\t\tObjectOwner: o.address?.address!,\n\t\t\t} as HaneulClientTypes.ObjectOwner;\n\t\tcase 'Immutable':\n\t\t\treturn { $kind: 'Immutable', Immutable: true } as HaneulClientTypes.ObjectOwner;\n\t\tcase 'Shared':\n\t\t\treturn {\n\t\t\t\t$kind: 'Shared',\n\t\t\t\tShared: { initialSharedVersion: String(o.initialSharedVersion) },\n\t\t\t} as HaneulClientTypes.ObjectOwner;\n\t\tcase 'ConsensusAddressOwner':\n\t\t\treturn {\n\t\t\t\t$kind: 'ConsensusAddressOwner',\n\t\t\t\tConsensusAddressOwner: {\n\t\t\t\t\towner: o.address?.address!,\n\t\t\t\t\tstartVersion: String(o.startVersion),\n\t\t\t\t},\n\t\t\t} as HaneulClientTypes.ObjectOwner;\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown GraphQL owner type: ${o.__typename}`);\n\t}\n}\n\nexport async function queryEvents(\n\tclient: KioskCompatibleClient,\n\teventType: string,\n): Promise<{ json: unknown }[]> {\n\tif (isHaneulGraphQLClient(client)) {\n\t\tconst query = graphql(`\n\t\t\tquery QueryEvents($eventType: String!) {\n\t\t\t\tevents(filter: { eventType: $eventType }, first: 50) {\n\t\t\t\t\tnodes {\n\t\t\t\t\t\tcontents {\n\t\t\t\t\t\t\tjson\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t`);\n\n\t\tconst result = await client.query({\n\t\t\tquery,\n\t\t\tvariables: { eventType },\n\t\t});\n\n\t\treturn (\n\t\t\tresult.data?.events?.nodes.map((event) => ({\n\t\t\t\tjson: event.contents?.json,\n\t\t\t})) ?? []\n\t\t);\n\t}\n\n\tif (isHaneulJsonRpcClient(client)) {\n\t\tconst events = await client.queryEvents({\n\t\t\tquery: { MoveEventType: eventType },\n\t\t});\n\n\t\treturn events.data?.map((d) => ({ json: d.parsedJson })) ?? [];\n\t}\n\n\tthrow new Error(\n\t\t'Event querying is not supported by this client type. ' +\n\t\t\t'JSON-RPC and GraphQL clients support event querying, but gRPC does not. ' +\n\t\t\t'Please use a JSON-RPC or GraphQL client, or provide the required IDs directly.',\n\t);\n}\n"],"mappings":";;;;;;;AAaA,MAAM,sBAAsB;AAE5B,MAAM,+BAA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V,SAAQ,EAAE,YAAV;EACC,KAAK,eACJ,QAAO;GACN,OAAO;GACP,cAAc,EAAE,SAAS;GACzB;EACF,KAAK,cACJ,QAAO;GACN,OAAO;GACP,aAAa,EAAE,SAAS;GACxB;EACF,KAAK,YACJ,QAAO;GAAE,OAAO;GAAa,WAAW;GAAM;EAC/C,KAAK,SACJ,QAAO;GACN,OAAO;GACP,QAAQ,EAAE,sBAAsB,OAAO,EAAE,qBAAqB,EAAE;GAChE;EACF,KAAK,wBACJ,QAAO;GACN,OAAO;GACP,uBAAuB;IACtB,OAAO,EAAE,SAAS;IAClB,cAAc,OAAO,EAAE,aAAa;IACpC;GACD;EACF,QACC,OAAM,IAAI,MAAM,+BAA+B,EAAE,aAAa;;;AAIjE,eAAsB,YACrB,QACA,WAC+B;AAC/B,KAAI,sBAAsB,OAAO,EAAE;EAClC,MAAM,QAAQ,QAAQ;;;;;;;;;;IAUpB;AAOF,UALe,MAAM,OAAO,MAAM;GACjC;GACA,WAAW,EAAE,WAAW;GACxB,CAAC,EAGM,MAAM,QAAQ,MAAM,KAAK,WAAW,EAC1C,MAAM,MAAM,UAAU,MACtB,EAAE,IAAI,EAAE;;AAIX,KAAI,sBAAsB,OAAO,CAKhC,SAJe,MAAM,OAAO,YAAY,EACvC,OAAO,EAAE,eAAe,WAAW,EACnC,CAAC,EAEY,MAAM,KAAK,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE;AAG/D,OAAM,IAAI,MACT,8MAGA"}
@@ -7,7 +7,6 @@ import { HaneulJsonRpcClient } from "@haneullabs/haneul/jsonRpc";
7
7
  import { HaneulClientTypes } from "@haneullabs/haneul/client";
8
8
 
9
9
  //#region src/types/index.d.ts
10
-
11
10
  /**
12
11
  * A valid argument for any of the Kiosk functions.
13
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;AAgBA;AAKY,KALA,cAAA,GAKkB,MAAA,GALQ,yBAKR;;;;AAGE,KAHpB,kBAAA,GAGoB;EAGpB,MAAA,EALH,qBAKwB;WAJvB,iBAAA,CAAkB;eACd;;KAGF,qBAAA,GAAwB,sBAAsB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/types/index.ts"],"mappings":";;;;;;;;;;;AAgBA;KAAY,cAAA,YAA0B,yBAAA;;;;KAK1B,kBAAA;EACX,MAAA,EAAQ,qBAAA;EACR,OAAA,EAAS,iBAAA,CAAkB,OAAA;EAC3B,UAAA,GAAa,kBAAA;AAAA;AAAA,KAGF,qBAAA,GAAwB,mBAAA,GAAsB,mBAAA"}
@@ -58,16 +58,14 @@ type PurchaseOptionalParams = {
58
58
  * Holds a `u64` value - the price of the item.
59
59
  */
60
60
  type KioskListing = {
61
- /** The ID of the Item */
62
- objectId: string;
61
+ /** The ID of the Item */objectId: string;
63
62
  /**
64
63
  * Whether or not there's a `PurchaseCap` issued. `true` means that
65
64
  * the listing is controlled by some logic and can't be purchased directly.
66
65
  *
67
66
  * TODO: consider renaming the field for better indication.
68
67
  */
69
- isExclusive: boolean;
70
- /** The ID of the listing */
68
+ isExclusive: boolean; /** The ID of the listing */
71
69
  listingId: string;
72
70
  price?: string;
73
71
  };
@@ -75,10 +73,10 @@ type KioskDisplay = {
75
73
  data: Record<string, string> | null;
76
74
  error: string | null;
77
75
  };
78
- type ObjectWithDisplay = HaneulClientTypes.Object<{
76
+ type ObjectWithDisplay = Omit<HaneulClientTypes.Object<{
79
77
  content: true;
80
78
  previousTransaction: true;
81
- }> & {
79
+ }>, 'display'> & {
82
80
  display?: KioskDisplay;
83
81
  };
84
82
  /**
@@ -86,32 +84,23 @@ type ObjectWithDisplay = HaneulClientTypes.Object<{
86
84
  * Holds an Item `T`. The type of the item is known upfront.
87
85
  */
88
86
  type KioskItem = {
89
- /** The ID of the Item */
90
- objectId: string;
91
- /** The type of the Item */
92
- type: string;
93
- /** Whether the item is Locked (there must be a `Lock` Dynamic Field) */
94
- isLocked: boolean;
95
- /** Optional listing */
96
- listing?: KioskListing;
97
- /** The ID of the kiosk the item is placed in */
98
- kioskId: string;
99
- /** Optional object data with display metadata */
87
+ /** The ID of the Item */objectId: string; /** The type of the Item */
88
+ type: string; /** Whether the item is Locked (there must be a `Lock` Dynamic Field) */
89
+ isLocked: boolean; /** Optional listing */
90
+ listing?: KioskListing; /** The ID of the kiosk the item is placed in */
91
+ kioskId: string; /** Optional object data with display metadata */
100
92
  data?: ObjectWithDisplay;
101
93
  };
102
94
  /** The overview type returned from `getKiosk` */
103
95
  type KioskExtensionOverview = {
104
- /** The ID of the extension's DF */
105
- objectId: string;
106
- /** The inner type of the Extension */
96
+ /** The ID of the extension's DF */objectId: string; /** The inner type of the Extension */
107
97
  type: string;
108
98
  };
109
99
  /**
110
100
  * Hold the KioskExtension data
111
101
  */
112
102
  type KioskExtension = KioskExtensionOverview & {
113
- /** These fields are only there if we have `withExtensions` flag */
114
- isEnabled: boolean;
103
+ /** These fields are only there if we have `withExtensions` flag */isEnabled: boolean;
115
104
  permissions: string;
116
105
  storageId: string;
117
106
  storageSize: number;
@@ -132,11 +121,8 @@ type PagedKioskData = {
132
121
  hasNextPage: boolean;
133
122
  };
134
123
  type FetchKioskOptions = {
135
- /** Include the base kiosk object, which includes the profits, the owner and the base fields. */
136
- withKioskFields?: boolean;
137
- /** Include the listing prices. */
138
- withListingPrices?: boolean;
139
- /** Include the objects for the Items in the kiosk. */
124
+ /** Include the base kiosk object, which includes the profits, the owner and the base fields. */withKioskFields?: boolean; /** Include the listing prices. */
125
+ withListingPrices?: boolean; /** Include the objects for the Items in the kiosk. */
140
126
  withObjects?: boolean;
141
127
  };
142
128
  type OwnedKiosks = {
@@ -1 +1 @@
1
- {"version":3,"file":"kiosk.d.mts","names":[],"sources":["../../src/types/kiosk.ts"],"sourcesContent":[],"mappings":";;;;;;cAWa,YAAA;AAAb;AAGa,cAAA,UAAA,GAAU,kFAAA;AAGvB;AAGa,cAHA,eAAA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,eAAA;EACX,SAAA,GAAY,MAAA;AAAA;AAAA,KAGD,MAAA;EAAW,QAAA;EAAkB,MAAA;AAAA;AAAA,KAC7B,aAAA;EAAkB,QAAA;EAAkB,IAAA,EAAM,cAAA;AAAA;AAAA,KAC1C,SAAA;EAAc,QAAA;EAAkB,IAAA,EAAM,mBAAA;AAAA;AAAA,KACtC,KAAA;EAAU,KAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"kiosk.mjs","names":[],"sources":["../../src/types/kiosk.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TransactionArgument } from '@haneullabs/haneul/transactions';\n\nimport type { ObjectArgument } from './index.js';\n\nimport { HANEUL_FRAMEWORK_ADDRESS } from '@haneullabs/haneul/utils';\nimport { HaneulClientTypes } from '@haneullabs/haneul/client';\n\n/** The Kiosk module. */\nexport const KIOSK_MODULE = `${HANEUL_FRAMEWORK_ADDRESS}::kiosk`;\n\n/** The Kiosk type. */\nexport const KIOSK_TYPE = `${KIOSK_MODULE}::Kiosk`;\n\n/** The Kiosk Owner Cap Type */\nexport const KIOSK_OWNER_CAP = `${KIOSK_MODULE}::KioskOwnerCap`;\n\n/** The Kiosk Item Type */\nexport const KIOSK_ITEM = `${KIOSK_MODULE}::Item`;\n\n/** The Kiosk Listing Type */\nexport const KIOSK_LISTING = `${KIOSK_MODULE}::Listing`;\n\n/** The Kiosk Lock Type */\nexport const KIOSK_LOCK = `${KIOSK_MODULE}::Lock`;\n\n/** The Kiosk PurchaseCap type */\nexport const KIOSK_PURCHASE_CAP = `${KIOSK_MODULE}::PurchaseCap`;\n\n/**\n * The Kiosk object fields (for BCS queries).\n */\nexport type Kiosk = {\n\tid: string;\n\tprofits: string;\n\towner: string;\n\titemCount: number;\n\tallowExtensions: boolean;\n};\n\n/**\n * PurchaseCap object fields (for BCS queries).\n */\nexport type PurchaseCap = {\n\tid: string;\n\tkioskId: string;\n\titemId: string;\n\tminPrice: string;\n};\n\n/**\n * The response type of a successful purchase flow.\n * Returns the item, and a `canTransfer` param.\n */\nexport type PurchaseAndResolvePoliciesResponse = {\n\titem: TransactionArgument;\n\tcanTransfer: boolean;\n};\n\n/**\n * Optional parameters for `purchaseAndResolvePolicies` flow.\n * This gives us the chance to extend the function in further releases\n * without introducing more breaking changes.\n */\nexport type PurchaseOptionalParams = {\n\townedKiosk?: ObjectArgument;\n\townedKioskCap?: ObjectArgument;\n};\n\n/**\n * A dynamic field `Listing { ID, isExclusive }` attached to the Kiosk.\n * Holds a `u64` value - the price of the item.\n */\nexport type KioskListing = {\n\t/** The ID of the Item */\n\tobjectId: string;\n\t/**\n\t * Whether or not there's a `PurchaseCap` issued. `true` means that\n\t * the listing is controlled by some logic and can't be purchased directly.\n\t *\n\t * TODO: consider renaming the field for better indication.\n\t */\n\tisExclusive: boolean;\n\t/** The ID of the listing */\n\tlistingId: string;\n\tprice?: string;\n};\n\nexport type KioskDisplay = {\n\tdata: Record<string, string> | null;\n\terror: string | null;\n};\n\nexport type ObjectWithDisplay = HaneulClientTypes.Object<{\n\tcontent: true;\n\tpreviousTransaction: true;\n}> & {\n\tdisplay?: KioskDisplay;\n};\n\n/**\n * A dynamic field `Item { ID }` attached to the Kiosk.\n * Holds an Item `T`. The type of the item is known upfront.\n */\nexport type KioskItem = {\n\t/** The ID of the Item */\n\tobjectId: string;\n\t/** The type of the Item */\n\ttype: string;\n\t/** Whether the item is Locked (there must be a `Lock` Dynamic Field) */\n\tisLocked: boolean;\n\t/** Optional listing */\n\tlisting?: KioskListing;\n\t/** The ID of the kiosk the item is placed in */\n\tkioskId: string;\n\t/** Optional object data with display metadata */\n\tdata?: ObjectWithDisplay;\n};\n\n/** The overview type returned from `getKiosk` */\nexport type KioskExtensionOverview = {\n\t/** The ID of the extension's DF */\n\tobjectId: string;\n\t/** The inner type of the Extension */\n\ttype: string;\n};\n/**\n * Hold the KioskExtension data\n */\nexport type KioskExtension = KioskExtensionOverview & {\n\t/** These fields are only there if we have `withExtensions` flag */\n\tisEnabled: boolean;\n\tpermissions: string;\n\tstorageId: string;\n\tstorageSize: number;\n};\n\n/**\n * Aggregated data from the Kiosk.\n */\nexport type KioskData = {\n\titems: KioskItem[];\n\titemIds: string[];\n\tlistingIds: string[];\n\tkiosk?: Kiosk;\n\textensions: KioskExtensionOverview[]; // type will be defined on later versions of the SDK.\n};\n\nexport type PagedKioskData = {\n\tdata: KioskData;\n\tnextCursor: string | null | undefined;\n\thasNextPage: boolean;\n};\n\nexport type FetchKioskOptions = {\n\t/** Include the base kiosk object, which includes the profits, the owner and the base fields. */\n\twithKioskFields?: boolean;\n\t/** Include the listing prices. */\n\twithListingPrices?: boolean;\n\t/** Include the objects for the Items in the kiosk. */\n\twithObjects?: boolean;\n};\n\nexport type OwnedKiosks = {\n\tkioskOwnerCaps: KioskOwnerCap[];\n\tkioskIds: string[];\n\tnextCursor: string | null;\n\thasNextPage: boolean;\n};\n\nexport type KioskOwnerCap = {\n\tisPersonal?: boolean;\n\tobjectId: string;\n\tkioskId: string;\n\tdigest: string;\n\tversion: string;\n};\n\nexport type PurchaseOptions = {\n\textraArgs?: Record<string, any>;\n};\n\nexport type ItemId = { itemType: string; itemId: string };\nexport type ItemReference = { itemType: string; item: ObjectArgument };\nexport type ItemValue = { itemType: string; item: TransactionArgument };\nexport type Price = { price: string | bigint };\n"],"mappings":";;;;AAWA,MAAa,eAAe,GAAG,yBAAyB;;AAGxD,MAAa,aAAa,GAAG,aAAa;;AAG1C,MAAa,kBAAkB,GAAG,aAAa;;AAG/C,MAAa,aAAa,GAAG,aAAa;;AAG1C,MAAa,gBAAgB,GAAG,aAAa;;AAG7C,MAAa,aAAa,GAAG,aAAa;;AAG1C,MAAa,qBAAqB,GAAG,aAAa"}
1
+ {"version":3,"file":"kiosk.mjs","names":[],"sources":["../../src/types/kiosk.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TransactionArgument } from '@haneullabs/haneul/transactions';\n\nimport type { ObjectArgument } from './index.js';\n\nimport { HANEUL_FRAMEWORK_ADDRESS } from '@haneullabs/haneul/utils';\nimport { HaneulClientTypes } from '@haneullabs/haneul/client';\n\n/** The Kiosk module. */\nexport const KIOSK_MODULE = `${HANEUL_FRAMEWORK_ADDRESS}::kiosk`;\n\n/** The Kiosk type. */\nexport const KIOSK_TYPE = `${KIOSK_MODULE}::Kiosk`;\n\n/** The Kiosk Owner Cap Type */\nexport const KIOSK_OWNER_CAP = `${KIOSK_MODULE}::KioskOwnerCap`;\n\n/** The Kiosk Item Type */\nexport const KIOSK_ITEM = `${KIOSK_MODULE}::Item`;\n\n/** The Kiosk Listing Type */\nexport const KIOSK_LISTING = `${KIOSK_MODULE}::Listing`;\n\n/** The Kiosk Lock Type */\nexport const KIOSK_LOCK = `${KIOSK_MODULE}::Lock`;\n\n/** The Kiosk PurchaseCap type */\nexport const KIOSK_PURCHASE_CAP = `${KIOSK_MODULE}::PurchaseCap`;\n\n/**\n * The Kiosk object fields (for BCS queries).\n */\nexport type Kiosk = {\n\tid: string;\n\tprofits: string;\n\towner: string;\n\titemCount: number;\n\tallowExtensions: boolean;\n};\n\n/**\n * PurchaseCap object fields (for BCS queries).\n */\nexport type PurchaseCap = {\n\tid: string;\n\tkioskId: string;\n\titemId: string;\n\tminPrice: string;\n};\n\n/**\n * The response type of a successful purchase flow.\n * Returns the item, and a `canTransfer` param.\n */\nexport type PurchaseAndResolvePoliciesResponse = {\n\titem: TransactionArgument;\n\tcanTransfer: boolean;\n};\n\n/**\n * Optional parameters for `purchaseAndResolvePolicies` flow.\n * This gives us the chance to extend the function in further releases\n * without introducing more breaking changes.\n */\nexport type PurchaseOptionalParams = {\n\townedKiosk?: ObjectArgument;\n\townedKioskCap?: ObjectArgument;\n};\n\n/**\n * A dynamic field `Listing { ID, isExclusive }` attached to the Kiosk.\n * Holds a `u64` value - the price of the item.\n */\nexport type KioskListing = {\n\t/** The ID of the Item */\n\tobjectId: string;\n\t/**\n\t * Whether or not there's a `PurchaseCap` issued. `true` means that\n\t * the listing is controlled by some logic and can't be purchased directly.\n\t *\n\t * TODO: consider renaming the field for better indication.\n\t */\n\tisExclusive: boolean;\n\t/** The ID of the listing */\n\tlistingId: string;\n\tprice?: string;\n};\n\nexport type KioskDisplay = {\n\tdata: Record<string, string> | null;\n\terror: string | null;\n};\n\nexport type ObjectWithDisplay = Omit<\n\tHaneulClientTypes.Object<{\n\t\tcontent: true;\n\t\tpreviousTransaction: true;\n\t}>,\n\t'display'\n> & {\n\tdisplay?: KioskDisplay;\n};\n\n/**\n * A dynamic field `Item { ID }` attached to the Kiosk.\n * Holds an Item `T`. The type of the item is known upfront.\n */\nexport type KioskItem = {\n\t/** The ID of the Item */\n\tobjectId: string;\n\t/** The type of the Item */\n\ttype: string;\n\t/** Whether the item is Locked (there must be a `Lock` Dynamic Field) */\n\tisLocked: boolean;\n\t/** Optional listing */\n\tlisting?: KioskListing;\n\t/** The ID of the kiosk the item is placed in */\n\tkioskId: string;\n\t/** Optional object data with display metadata */\n\tdata?: ObjectWithDisplay;\n};\n\n/** The overview type returned from `getKiosk` */\nexport type KioskExtensionOverview = {\n\t/** The ID of the extension's DF */\n\tobjectId: string;\n\t/** The inner type of the Extension */\n\ttype: string;\n};\n/**\n * Hold the KioskExtension data\n */\nexport type KioskExtension = KioskExtensionOverview & {\n\t/** These fields are only there if we have `withExtensions` flag */\n\tisEnabled: boolean;\n\tpermissions: string;\n\tstorageId: string;\n\tstorageSize: number;\n};\n\n/**\n * Aggregated data from the Kiosk.\n */\nexport type KioskData = {\n\titems: KioskItem[];\n\titemIds: string[];\n\tlistingIds: string[];\n\tkiosk?: Kiosk;\n\textensions: KioskExtensionOverview[]; // type will be defined on later versions of the SDK.\n};\n\nexport type PagedKioskData = {\n\tdata: KioskData;\n\tnextCursor: string | null | undefined;\n\thasNextPage: boolean;\n};\n\nexport type FetchKioskOptions = {\n\t/** Include the base kiosk object, which includes the profits, the owner and the base fields. */\n\twithKioskFields?: boolean;\n\t/** Include the listing prices. */\n\twithListingPrices?: boolean;\n\t/** Include the objects for the Items in the kiosk. */\n\twithObjects?: boolean;\n};\n\nexport type OwnedKiosks = {\n\tkioskOwnerCaps: KioskOwnerCap[];\n\tkioskIds: string[];\n\tnextCursor: string | null;\n\thasNextPage: boolean;\n};\n\nexport type KioskOwnerCap = {\n\tisPersonal?: boolean;\n\tobjectId: string;\n\tkioskId: string;\n\tdigest: string;\n\tversion: string;\n};\n\nexport type PurchaseOptions = {\n\textraArgs?: Record<string, any>;\n};\n\nexport type ItemId = { itemType: string; itemId: string };\nexport type ItemReference = { itemType: string; item: ObjectArgument };\nexport type ItemValue = { itemType: string; item: TransactionArgument };\nexport type Price = { price: string | bigint };\n"],"mappings":";;;;AAWA,MAAa,eAAe,GAAG,yBAAyB;;AAGxD,MAAa,aAAa,GAAG,aAAa;;AAG1C,MAAa,kBAAkB,GAAG,aAAa;;AAG/C,MAAa,aAAa,GAAG,aAAa;;AAG1C,MAAa,gBAAgB,GAAG,aAAa;;AAG7C,MAAa,aAAa,GAAG,aAAa;;AAG1C,MAAa,qBAAqB,GAAG,aAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"transfer-policy.d.mts","names":[],"sources":["../../src/types/transfer-policy.ts"],"sourcesContent":[],"mappings":";;;;;;;cAYa,sBAAA;AAAb;AAGa,cAAA,6BAAA,GAA6B,4GAAA;AAG1C;AAGa,cAHA,oBAAA,GAGwB,qGAAA;AAGrC;AAGa,cANA,wBAAA,GAMY,wGAAA;AAKzB;AAOY,cAfC,eAAA,GAoBL,uBAAW;AAInB;AAQY,cA7BC,YAAA,GA6BkB,oBAAA;;;;AAOvB,KA/BI,iBAAA,GA+BJ;EACG,QAAA,EAAA,MAAA;EACO,WAAA,EAAA,MAAA;EACF,IAAA,EAAA,MAAA;CAEJ;;AACa,KA9Bb,cAAA,GA8Ba;;;;;SAzBjB;;;KAII,qBAAA;;;KAQA,mBAAA;eACE;;;;YAIH;eACG;SACN;YACG;mBACO;iBACF;;aAEJ;eACE"}
1
+ {"version":3,"file":"transfer-policy.d.mts","names":[],"sources":["../../src/types/transfer-policy.ts"],"mappings":";;;;;;;cAYa,sBAAA;AAAb;AAAA,cAGa,6BAAA;;cAGA,oBAAA;;cAGA,wBAAA;;cAGA,eAAA;;cAGA,YAAA;AATb;;;AAAA,KAcY,iBAAA;EACX,QAAA;EACA,WAAA;EACA,IAAA;AAAA;;KAIW,cAAA;EACX,EAAA;EACA,IAAA;EACA,OAAA;EACA,KAAA;EACA,KAAA,EAAO,WAAA;AAAA;;KAII,qBAAA;EACX,EAAA;AAAA;AAAA,KAOW,mBAAA;EACX,WAAA,EAAa,WAAA;EACb,QAAA;EACA,MAAA;EACA,KAAA;EACA,QAAA,EAAU,cAAA;EACV,WAAA,EAAa,cAAA;EACb,KAAA,EAAO,cAAA;EACP,QAAA,EAAU,cAAA;EACV,eAAA,EAAiB,yBAAA;EACjB,aAAA,EAAe,yBAAA;EACf,SAAA;EACA,SAAA,EAAW,MAAA;EACX,WAAA,EAAa,WAAA;AAAA"}
package/dist/utils.d.mts CHANGED
@@ -10,7 +10,7 @@ declare function extractKioskData(data: DynamicFieldInfo[], listings: KioskListi
10
10
  /**
11
11
  * A helper that attaches the listing prices to kiosk listings.
12
12
  */
13
- declare function attachListingsAndPrices(kioskData: KioskData, listings: KioskListing[], listingObjects: HaneulClientTypes.Object[]): void;
13
+ declare function attachListingsAndPrices(kioskData: KioskData, listings: KioskListing[], listingObjects: ObjectWithDisplay[]): void;
14
14
  /**
15
15
  * A helper that attaches object data to kiosk items.
16
16
  * Works with core API objects that contain BCS content.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.mts","names":[],"sources":["../src/utils.ts"],"sourcesContent":[],"mappings":";;;;;;KAWY,gBAAA,GAAmB,iBAAA,CAAkB;iBAE3B,cAAA,SAAuB,gCAAgC,QAAQ;iBAsBrE,gBAAA,OACT,8BACI,2DAGR;AA7BH;AAEA;;AAAq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BAAA,EACR,QAAA,UACA,UAAA,EAAY,mBAAA,WACV,OAAA,CAAQ,gBAAA;;AAhJX;;;;;iBA2KgB,uBAAA,CAAwB,UAAA;AAAA,iBAOxB,qBAAA,CAAsB,IAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","names":["KioskStruct"],"sources":["../src/utils.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@haneullabs/haneul/bcs';\nimport { PaginationArguments } from '@haneullabs/haneul/jsonRpc';\nimport type { ClientWithCoreApi, HaneulClientTypes } from '@haneullabs/haneul/client';\nimport { normalizeStructTag, normalizeHaneulAddress, parseStructTag } from '@haneullabs/haneul/utils';\n\nimport { Item, Listing, Lock, Kiosk as KioskStruct } from './contracts/0x2/kiosk.js';\nimport type { Kiosk, KioskData, KioskListing, ObjectWithDisplay } from './types/index.js';\n\nexport type DynamicFieldInfo = HaneulClientTypes.ListDynamicFieldsResponse['dynamicFields'][number];\n\nexport async function getKioskObject(client: ClientWithCoreApi, id: string): Promise<Kiosk> {\n\tconst { object } = await client.core.getObject({\n\t\tobjectId: id,\n\t\tinclude: { content: true },\n\t});\n\n\tif (!object.content) {\n\t\tthrow new Error(`Kiosk ${id} not found or has no content`);\n\t}\n\n\tconst parsed = KioskStruct.parse(object.content);\n\n\treturn {\n\t\tid: parsed.id,\n\t\tprofits: parsed.profits.value.toString(),\n\t\towner: parsed.owner,\n\t\titemCount: parsed.item_count,\n\t\tallowExtensions: parsed.allow_extensions,\n\t};\n}\n\n// helper to extract kiosk data from dynamic fields.\nexport function extractKioskData(\n\tdata: DynamicFieldInfo[],\n\tlistings: KioskListing[],\n\tlockedItemIds: string[],\n\tkioskId: string,\n): KioskData {\n\treturn data.reduce<KioskData>(\n\t\t(acc: KioskData, val: DynamicFieldInfo) => {\n\t\t\tconst type = val.name.type;\n\n\t\t\tconst parsedType = parseStructTag(type);\n\t\t\tconst baseType = `${normalizeHaneulAddress(parsedType.address)}::${parsedType.module}::${parsedType.name}`;\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Item'\n\t\t\t) {\n\t\t\t\tconst parsed = Item.parse(val.name.bcs);\n\t\t\t\tacc.itemIds.push(parsed.id);\n\t\t\t\tacc.items.push({\n\t\t\t\t\tobjectId: parsed.id,\n\t\t\t\t\ttype: val.valueType,\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tkioskId,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Listing'\n\t\t\t) {\n\t\t\t\tconst parsed = Listing.parse(val.name.bcs);\n\n\t\t\t\tacc.listingIds.push(val.fieldId);\n\t\t\t\tlistings.push({\n\t\t\t\t\tobjectId: parsed.id,\n\t\t\t\t\tlistingId: val.fieldId,\n\t\t\t\t\tisExclusive: parsed.is_exclusive,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Lock'\n\t\t\t) {\n\t\t\t\tlockedItemIds?.push(Lock.parse(val.name.bcs).id);\n\t\t\t}\n\n\t\t\t// Check for ExtensionKey type\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk_extension::ExtensionKey'\n\t\t\t) {\n\t\t\t\tacc.extensions.push({\n\t\t\t\t\tobjectId: val.fieldId,\n\t\t\t\t\ttype: normalizeStructTag(parsedType.typeParams[0]),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn acc;\n\t\t},\n\t\t{ items: [], itemIds: [], listingIds: [], extensions: [] },\n\t);\n}\n\n/**\n * A helper that attaches the listing prices to kiosk listings.\n */\nexport function attachListingsAndPrices(\n\tkioskData: KioskData,\n\tlistings: KioskListing[],\n\tlistingObjects: HaneulClientTypes.Object[],\n) {\n\tconst itemListings = listings.reduce<Record<string, KioskListing>>(\n\t\t(acc: Record<string, KioskListing>, item, idx) => {\n\t\t\tacc[item.objectId] = { ...item };\n\n\t\t\t// return in case we don't have any listing objects.\n\t\t\t// that's the case when we don't have the `listingPrices` included.\n\t\t\tif (listingObjects.length === 0) return acc;\n\n\t\t\tconst obj = listingObjects[idx];\n\n\t\t\t// Parse BCS content to extract the price (u64 value)\n\t\t\tif (obj.content) {\n\t\t\t\tacc[item.objectId].price = bcs.u64().parse(obj.content).toString();\n\t\t\t}\n\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\tkioskData.items.forEach((item) => {\n\t\titem.listing = itemListings[item.objectId] || undefined;\n\t});\n}\n\n/**\n * A helper that attaches object data to kiosk items.\n * Works with core API objects that contain BCS content.\n */\nexport function attachObjects(kioskData: KioskData, objects: ObjectWithDisplay[]) {\n\tconst mapping = objects.reduce<Record<string, ObjectWithDisplay>>(\n\t\t(acc: Record<string, ObjectWithDisplay>, obj) => {\n\t\t\tacc[obj.objectId] = obj;\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\tkioskData.items.forEach((item) => {\n\t\titem.data = mapping[item.objectId] || undefined;\n\t});\n}\n\n/**\n * A Helper to attach locked state to items in Kiosk Data.\n */\nexport function attachLockedItems(kioskData: KioskData, lockedItemIds: string[]) {\n\t// map lock status in an array of type { item_id: true }\n\tconst lockedStatuses = lockedItemIds.reduce<Record<string, boolean>>(\n\t\t(acc: Record<string, boolean>, item: string) => {\n\t\t\tacc[item] = true;\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\t// parse lockedItemIds and attach their locked status.\n\tkioskData.items.forEach((item) => {\n\t\titem.isLocked = lockedStatuses[item.objectId] || false;\n\t});\n}\n\n/**\n * A helper to fetch all dynamic field pages.\n * We need that to fetch the kiosk DFs consistently, until we have\n * RPC calls that allow filtering of Type / batch fetching of spec\n */\nexport async function getAllDynamicFields(\n\tclient: ClientWithCoreApi,\n\tparentId: string,\n\tpagination: PaginationArguments<string>,\n): Promise<DynamicFieldInfo[]> {\n\tlet hasNextPage = true;\n\tlet cursor: string | null = null;\n\tconst data: DynamicFieldInfo[] = [];\n\n\twhile (hasNextPage) {\n\t\tconst result = await client.core.listDynamicFields({\n\t\t\tparentId,\n\t\t\tlimit: pagination.limit || undefined,\n\t\t\tcursor,\n\t\t});\n\n\t\tdata.push(...result.dynamicFields);\n\n\t\thasNextPage = result.hasNextPage;\n\t\tcursor = result.cursor;\n\t}\n\n\treturn data;\n}\n\n/**\n * Converts a number to basis points.\n * Supports up to 2 decimal points.\n * E.g 9.95 -> 995\n * @param percentage A percentage amount in the range [0, 100] including decimals.\n */\nexport function percentageToBasisPoints(percentage: number) {\n\tif (percentage < 0 || percentage > 100)\n\t\tthrow new Error('Percentage needs to be in the [0,100] range.');\n\treturn Math.ceil(percentage * 100);\n}\n\n// Normalizes the packageId part of a rule's type.\nexport function getNormalizedRuleType(rule: string) {\n\tconst normalizedRuleAddress = rule.split('::');\n\tnormalizedRuleAddress[0] = normalizeHaneulAddress(normalizedRuleAddress[0]);\n\treturn normalizedRuleAddress.join('::');\n}\n"],"mappings":";;;;;AAaA,eAAsB,eAAe,QAA2B,IAA4B;CAC3F,MAAM,EAAE,WAAW,MAAM,OAAO,KAAK,UAAU;EAC9C,UAAU;EACV,SAAS,EAAE,SAAS,MAAM;EAC1B,CAAC;AAEF,KAAI,CAAC,OAAO,QACX,OAAM,IAAI,MAAM,SAAS,GAAG,8BAA8B;CAG3D,MAAM,SAASA,MAAY,MAAM,OAAO,QAAQ;AAEhD,QAAO;EACN,IAAI,OAAO;EACX,SAAS,OAAO,QAAQ,MAAM,UAAU;EACxC,OAAO,OAAO;EACd,WAAW,OAAO;EAClB,iBAAiB,OAAO;EACxB;;AAIF,SAAgB,iBACf,MACA,UACA,eACA,SACY;AACZ,QAAO,KAAK,QACV,KAAgB,QAA0B;EAC1C,MAA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sB,SAA8B;CACjF,MAAM,UAAU,QAAQ,QACtB,KAAwC,QAAQ;AAChD,MAAI,IAAI,YAAY;AACpB,SAAO;IAER,EAAE,CACF;AAED,WAAU,MAAM,SAAS,SAAS;AACjC,OAAK,OAAO,QAAQ,KAAK,aAAa;GACrC;;;;;AAMH,SAAgB,kBAAkB,WAAsB,eAAyB;CAEhF,MAAM,iBAAiB,cAAc,QACnC,KAA8B,SAAiB;AAC/C,MAAI,QAAQ;AACZ,SAAO;IAER,EAAE,CACF;AAGD,WAAU,MAAM,SAAS,SAAS;AACjC,OAAK,WAAW,eAAe,KAAK,aAAa;GAChD;;;;;;;AAQH,eAAsB,oBACrB,QACA,UACA,YAC8B;CAC9B,IAAI,cAAc;CAClB,IAAI,SAAwB;CAC5B,MAAM,OAA2B,EAAE;AAEnC,QAAO,aAAa;EACnB,MAAM,SAAS,MAAM,OAAO,KAAK,kBAAkB;GAClD;GACA,OAAO,WAAW,SAAS;GAC3B;GACA,CAAC;AAEF,OAAK,KAAK,GAAG,OAAO,cAAc;AAElC,gBAAc,OAAO;AACrB,WAAS,OAAO;;AAGjB,QAAO;;;;;;;;AASR,SAAgB,wBAAwB,YAAoB;AAC3D,KAAI,aAAa,KAAK,aAAa,IAClC,OAAM,IAAI,MAAM,+CAA+C;AAChE,QAAO,KAAK,KAAK,aAAa,IAAI;;AAInC,SAAgB,sBAAsB,MAAc;CACnD,MAAM,wBAAwB,KAAK,MAAM,KAAK;AAC9C,uBAAsB,KAAK,uBAAuB,sBAAsB,GAAG;AAC3E,QAAO,sBAAsB,KAAK,KAAK"}
1
+ {"version":3,"file":"utils.mjs","names":["KioskStruct"],"sources":["../src/utils.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@haneullabs/haneul/bcs';\nimport { PaginationArguments } from '@haneullabs/haneul/jsonRpc';\nimport type { ClientWithCoreApi, HaneulClientTypes } from '@haneullabs/haneul/client';\nimport { normalizeStructTag, normalizeHaneulAddress, parseStructTag } from '@haneullabs/haneul/utils';\n\nimport { Item, Listing, Lock, Kiosk as KioskStruct } from './contracts/0x2/kiosk.js';\nimport type { Kiosk, KioskData, KioskListing, ObjectWithDisplay } from './types/index.js';\n\nexport type DynamicFieldInfo = HaneulClientTypes.ListDynamicFieldsResponse['dynamicFields'][number];\n\nexport async function getKioskObject(client: ClientWithCoreApi, id: string): Promise<Kiosk> {\n\tconst { object } = await client.core.getObject({\n\t\tobjectId: id,\n\t\tinclude: { content: true },\n\t});\n\n\tif (!object.content) {\n\t\tthrow new Error(`Kiosk ${id} not found or has no content`);\n\t}\n\n\tconst parsed = KioskStruct.parse(object.content);\n\n\treturn {\n\t\tid: parsed.id,\n\t\tprofits: parsed.profits.value.toString(),\n\t\towner: parsed.owner,\n\t\titemCount: parsed.item_count,\n\t\tallowExtensions: parsed.allow_extensions,\n\t};\n}\n\n// helper to extract kiosk data from dynamic fields.\nexport function extractKioskData(\n\tdata: DynamicFieldInfo[],\n\tlistings: KioskListing[],\n\tlockedItemIds: string[],\n\tkioskId: string,\n): KioskData {\n\treturn data.reduce<KioskData>(\n\t\t(acc: KioskData, val: DynamicFieldInfo) => {\n\t\t\tconst type = val.name.type;\n\n\t\t\tconst parsedType = parseStructTag(type);\n\t\t\tconst baseType = `${normalizeHaneulAddress(parsedType.address)}::${parsedType.module}::${parsedType.name}`;\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Item'\n\t\t\t) {\n\t\t\t\tconst parsed = Item.parse(val.name.bcs);\n\t\t\t\tacc.itemIds.push(parsed.id);\n\t\t\t\tacc.items.push({\n\t\t\t\t\tobjectId: parsed.id,\n\t\t\t\t\ttype: val.valueType,\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tkioskId,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Listing'\n\t\t\t) {\n\t\t\t\tconst parsed = Listing.parse(val.name.bcs);\n\n\t\t\t\tacc.listingIds.push(val.fieldId);\n\t\t\t\tlistings.push({\n\t\t\t\t\tobjectId: parsed.id,\n\t\t\t\t\tlistingId: val.fieldId,\n\t\t\t\t\tisExclusive: parsed.is_exclusive,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Lock'\n\t\t\t) {\n\t\t\t\tlockedItemIds?.push(Lock.parse(val.name.bcs).id);\n\t\t\t}\n\n\t\t\t// Check for ExtensionKey type\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk_extension::ExtensionKey'\n\t\t\t) {\n\t\t\t\tacc.extensions.push({\n\t\t\t\t\tobjectId: val.fieldId,\n\t\t\t\t\ttype: normalizeStructTag(parsedType.typeParams[0]),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn acc;\n\t\t},\n\t\t{ items: [], itemIds: [], listingIds: [], extensions: [] },\n\t);\n}\n\n/**\n * A helper that attaches the listing prices to kiosk listings.\n */\nexport function attachListingsAndPrices(\n\tkioskData: KioskData,\n\tlistings: KioskListing[],\n\tlistingObjects: ObjectWithDisplay[],\n) {\n\tconst itemListings = listings.reduce<Record<string, KioskListing>>(\n\t\t(acc: Record<string, KioskListing>, item, idx) => {\n\t\t\tacc[item.objectId] = { ...item };\n\n\t\t\t// return in case we don't have any listing objects.\n\t\t\t// that's the case when we don't have the `listingPrices` included.\n\t\t\tif (listingObjects.length === 0) return acc;\n\n\t\t\tconst obj = listingObjects[idx];\n\n\t\t\t// Parse BCS content to extract the price (u64 value)\n\t\t\tif (obj.content) {\n\t\t\t\tacc[item.objectId].price = bcs.u64().parse(obj.content).toString();\n\t\t\t}\n\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\tkioskData.items.forEach((item) => {\n\t\titem.listing = itemListings[item.objectId] || undefined;\n\t});\n}\n\n/**\n * A helper that attaches object data to kiosk items.\n * Works with core API objects that contain BCS content.\n */\nexport function attachObjects(kioskData: KioskData, objects: ObjectWithDisplay[]) {\n\tconst mapping = objects.reduce<Record<string, ObjectWithDisplay>>(\n\t\t(acc: Record<string, ObjectWithDisplay>, obj) => {\n\t\t\tacc[obj.objectId] = obj;\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\tkioskData.items.forEach((item) => {\n\t\titem.data = mapping[item.objectId] || undefined;\n\t});\n}\n\n/**\n * A Helper to attach locked state to items in Kiosk Data.\n */\nexport function attachLockedItems(kioskData: KioskData, lockedItemIds: string[]) {\n\t// map lock status in an array of type { item_id: true }\n\tconst lockedStatuses = lockedItemIds.reduce<Record<string, boolean>>(\n\t\t(acc: Record<string, boolean>, item: string) => {\n\t\t\tacc[item] = true;\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\t// parse lockedItemIds and attach their locked status.\n\tkioskData.items.forEach((item) => {\n\t\titem.isLocked = lockedStatuses[item.objectId] || false;\n\t});\n}\n\n/**\n * A helper to fetch all dynamic field pages.\n * We need that to fetch the kiosk DFs consistently, until we have\n * RPC calls that allow filtering of Type / batch fetching of spec\n */\nexport async function getAllDynamicFields(\n\tclient: ClientWithCoreApi,\n\tparentId: string,\n\tpagination: PaginationArguments<string>,\n): Promise<DynamicFieldInfo[]> {\n\tlet hasNextPage = true;\n\tlet cursor: string | null = null;\n\tconst data: DynamicFieldInfo[] = [];\n\n\twhile (hasNextPage) {\n\t\tconst result = await client.core.listDynamicFields({\n\t\t\tparentId,\n\t\t\tlimit: pagination.limit || undefined,\n\t\t\tcursor,\n\t\t});\n\n\t\tdata.push(...result.dynamicFields);\n\n\t\thasNextPage = result.hasNextPage;\n\t\tcursor = result.cursor;\n\t}\n\n\treturn data;\n}\n\n/**\n * Converts a number to basis points.\n * Supports up to 2 decimal points.\n * E.g 9.95 -> 995\n * @param percentage A percentage amount in the range [0, 100] including decimals.\n */\nexport function percentageToBasisPoints(percentage: number) {\n\tif (percentage < 0 || percentage > 100)\n\t\tthrow new Error('Percentage needs to be in the [0,100] range.');\n\treturn Math.ceil(percentage * 100);\n}\n\n// Normalizes the packageId part of a rule's type.\nexport function getNormalizedRuleType(rule: string) {\n\tconst normalizedRuleAddress = rule.split('::');\n\tnormalizedRuleAddress[0] = normalizeHaneulAddress(normalizedRuleAddress[0]);\n\treturn normalizedRuleAddress.join('::');\n}\n"],"mappings":";;;;;AAaA,eAAsB,eAAe,QAA2B,IAA4B;CAC3F,MAAM,EAAE,WAAW,MAAM,OAAO,KAAK,UAAU;EAC9C,UAAU;EACV,SAAS,EAAE,SAAS,MAAM;EAC1B,CAAC;AAEF,KAAI,CAAC,OAAO,QACX,OAAM,IAAI,MAAM,SAAS,GAAG,8BAA8B;CAG3D,MAAM,SAASA,MAAY,MAAM,OAAO,QAAQ;AAEhD,QAAO;EACN,IAAI,OAAO;EACX,SAAS,OAAO,QAAQ,MAAM,UAAU;EACxC,OAAO,OAAO;EACd,WAAW,OAAO;EAClB,iBAAiB,OAAO;EACxB;;AAIF,SAAgB,iBACf,MACA,UACA,eACA,SACY;AACZ,QAAO,KAAK,QACV,KAAgB,QAA0B;EAC1C,MAAM,OAAO,IAAI,KAAK;EAEtB,MAAM,aAAa,eAAe,KAAK;EACvC,MAAM,WAAW,GAAG,uBAAuB,WAAW,QAAQ,CAAC,IAAI,WAAW,OAAO,IAAI,WAAW;AAEpG,MACC,aACA,mFACC;GACD,MAAM,SAAS,KAAK,MAAM,IAAI,KAAK,IAAI;AACvC,OAAI,QAAQ,KAAK,OAAO,GAAG;AAC3B,OAAI,MAAM,KAAK;IACd,UAAU,OAAO;IACjB,MAAM,IAAI;IACV,UAAU;IACV;IACA,CAAC;;AAGH,MACC,aACA,sFACC;GACD,MAAM,SAAS,QAAQ,MAAM,IAAI,KAAK,IAAI;AAE1C,OAAI,W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ACrB,QACA,UACA,YAC8B;CAC9B,IAAI,cAAc;CAClB,IAAI,SAAwB;CAC5B,MAAM,OAA2B,EAAE;AAEnC,QAAO,aAAa;EACnB,MAAM,SAAS,MAAM,OAAO,KAAK,kBAAkB;GAClD;GACA,OAAO,WAAW,SAAS;GAC3B;GACA,CAAC;AAEF,OAAK,KAAK,GAAG,OAAO,cAAc;AAElC,gBAAc,OAAO;AACrB,WAAS,OAAO;;AAGjB,QAAO;;;;;;;;AASR,SAAgB,wBAAwB,YAAoB;AAC3D,KAAI,aAAa,KAAK,aAAa,IAClC,OAAM,IAAI,MAAM,+CAA+C;AAChE,QAAO,KAAK,KAAK,aAAa,IAAI;;AAInC,SAAgB,sBAAsB,MAAc;CACnD,MAAM,wBAAwB,KAAK,MAAM,KAAK;AAC9C,uBAAsB,KAAK,uBAAuB,sBAAsB,GAAG;AAC3E,QAAO,sBAAsB,KAAK,KAAK"}
@@ -0,0 +1,100 @@
1
+ # Advanced Examples
2
+
3
+ > Advanced Kiosk SDK usage patterns and examples
4
+
5
+ # Some extended examples
6
+
7
+ For these examples, assume you have the following data and functions available:
8
+
9
+ ```typescript
10
+ // a constant for bullshark's type.
11
+ const bullsharkType = `${packageId}::haneulfrens::HaneulFren<${packageId}::bullshark::Bullshark>`;
12
+ // a constant for capy's type.
13
+ const capyType = `${packageId}::haneulfrens::HaneulFren<${packageId}::capy::Capy>`;
14
+
15
+ // initialize the client with the kiosk extension.
16
+ const client = new HaneulJsonRpcClient({
17
+ url: getJsonRpcFullnodeUrl('mainnet'),
18
+ network: 'mainnet',
19
+ }).$extend(kiosk());
20
+ ```
21
+
22
+ ## Minting a HaneulFren
23
+
24
+ This example demonstrates how to mint a HaneulFren.
25
+
26
+ ```typescript
27
+ async function mintFren(address: string) {
28
+ const { kioskOwnerCaps } = await client.kiosk.getOwnedKiosks({ address });
29
+
30
+ // Choose the first kiosk for simplicity. We could have extra logic here (e.g. let the user choose, pick a personal one, etc).
31
+ const cap = kioskOwnerCaps[0];
32
+
33
+ const tx = new Transaction();
34
+ const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });
35
+
36
+ // We're mixing the logic here. If the cap is undefined, we create a new kiosk.
37
+ if (!cap) kioskTx.create();
38
+
39
+ // Let's mint a capy here into the kiosk (either a new or an existing one).
40
+ tx.moveCall({
41
+ target: `${packageId}::haneulfrens::mint_app::mint`,
42
+ arguments: [kioskTx.getKiosk(), kioskTx.getKioskCap()],
43
+ typeArguments: [capyType],
44
+ });
45
+
46
+ // If we don't have a cap, that means we create a new kiosk for the user in this flow.
47
+ if (!cap) kioskTx.shareAndTransferCap(address);
48
+
49
+ kioskTx.finalize();
50
+
51
+ // sign and execute transaction.
52
+ await signAndExecuteTransaction({ tx: tx });
53
+ }
54
+ ```
55
+
56
+ ## Mixing two Haneulfrens
57
+
58
+ This example demonstrates how to use the Kiosk SDK to mix two `bullsharks`.
59
+
60
+ ```typescript
61
+ // We're mixing two frens.
62
+ async function mixFrens(firstFrenObjectId: string, secondFrenObjectId: string, cap: KioskOwnerCap) {
63
+ const tx = new Transaction();
64
+ const kioskTx = new KioskTransaction({ transaction: tx, kioskClient: client.kiosk, cap });
65
+
66
+ // borrow both frens.
67
+ const [fren1, promise1] = kioskTx.borrow({
68
+ itemType: bullsharkType,
69
+ itemId: firstFrenObjectId,
70
+ });
71
+
72
+ const [fren2, promise2] = kioskTx.borrow({
73
+ itemType: bullsharkType,
74
+ itemId: secondFrenObjectId,
75
+ });
76
+
77
+ // Let's call the mix function. We skip any payment related stuff here.
78
+ tx.moveCall({
79
+ target: `${packageId}::mix_app::mix`,
80
+ arguments: [fren1, fren2, kioskTx.getKiosk(), kioskTx.getKioskCap()],
81
+ typeArguments: [bullsharkType],
82
+ });
83
+
84
+ kioskTx
85
+ .return({
86
+ itemType: bullsharkType,
87
+ item: fren1,
88
+ promise: promise1,
89
+ })
90
+ .return({
91
+ itemType: bullsharkType,
92
+ item: fren2,
93
+ promise: promise2,
94
+ })
95
+ .finalize();
96
+
97
+ // sign and execute transaction.
98
+ await signAndExecuteTransaction({ tx: tx });
99
+ }
100
+ ```