@mysten/kiosk 0.8.10 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/bcs.d.ts +40 -2
- package/dist/cjs/bcs.js +22 -19
- package/dist/cjs/bcs.js.map +2 -2
- package/dist/cjs/client/kiosk-client.d.ts +1 -1
- package/dist/cjs/client/kiosk-client.js.map +1 -1
- package/dist/cjs/client/kiosk-transaction.d.ts +8 -6
- package/dist/cjs/client/kiosk-transaction.js +41 -54
- package/dist/cjs/client/kiosk-transaction.js.map +2 -2
- package/dist/cjs/client/tp-transaction.d.ts +6 -4
- package/dist/cjs/client/tp-transaction.js +24 -19
- package/dist/cjs/client/tp-transaction.js.map +2 -2
- package/dist/cjs/query/kiosk.d.ts +1 -1
- package/dist/cjs/query/kiosk.js +1 -1
- package/dist/cjs/query/kiosk.js.map +1 -1
- package/dist/cjs/query/transfer-policy.d.ts +2 -1
- package/dist/cjs/query/transfer-policy.js +3 -2
- package/dist/cjs/query/transfer-policy.js.map +3 -3
- package/dist/cjs/tx/kiosk.d.ts +14 -14
- package/dist/cjs/tx/kiosk.js +1 -1
- package/dist/cjs/tx/kiosk.js.map +2 -2
- package/dist/cjs/tx/personal-kiosk.d.ts +3 -3
- package/dist/cjs/tx/personal-kiosk.js.map +1 -1
- package/dist/cjs/tx/rules/attach.d.ts +5 -5
- package/dist/cjs/tx/rules/attach.js.map +1 -1
- package/dist/cjs/tx/rules/resolve.js +16 -16
- package/dist/cjs/tx/rules/resolve.js.map +2 -2
- package/dist/cjs/tx/transfer-policy.d.ts +7 -7
- package/dist/cjs/tx/transfer-policy.js +1 -1
- package/dist/cjs/tx/transfer-policy.js.map +1 -1
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/types/kiosk.d.ts +2 -2
- package/dist/cjs/types/kiosk.js.map +1 -1
- package/dist/cjs/types/transfer-policy.d.ts +5 -3
- package/dist/cjs/types/transfer-policy.js.map +1 -1
- package/dist/cjs/utils.d.ts +1 -1
- package/dist/cjs/utils.js +2 -2
- package/dist/cjs/utils.js.map +2 -2
- package/dist/esm/bcs.d.ts +40 -2
- package/dist/esm/bcs.js +22 -19
- package/dist/esm/bcs.js.map +2 -2
- package/dist/esm/client/kiosk-client.d.ts +1 -1
- package/dist/esm/client/kiosk-client.js.map +1 -1
- package/dist/esm/client/kiosk-transaction.d.ts +8 -6
- package/dist/esm/client/kiosk-transaction.js +41 -54
- package/dist/esm/client/kiosk-transaction.js.map +2 -2
- package/dist/esm/client/tp-transaction.d.ts +6 -4
- package/dist/esm/client/tp-transaction.js +24 -19
- package/dist/esm/client/tp-transaction.js.map +2 -2
- package/dist/esm/query/kiosk.d.ts +1 -1
- package/dist/esm/query/kiosk.js +1 -1
- package/dist/esm/query/kiosk.js.map +1 -1
- package/dist/esm/query/transfer-policy.d.ts +2 -1
- package/dist/esm/query/transfer-policy.js +4 -3
- package/dist/esm/query/transfer-policy.js.map +2 -2
- package/dist/esm/tx/kiosk.d.ts +14 -14
- package/dist/esm/tx/kiosk.js +1 -1
- package/dist/esm/tx/kiosk.js.map +2 -2
- package/dist/esm/tx/personal-kiosk.d.ts +3 -3
- package/dist/esm/tx/personal-kiosk.js.map +1 -1
- package/dist/esm/tx/rules/attach.d.ts +5 -5
- package/dist/esm/tx/rules/attach.js.map +1 -1
- package/dist/esm/tx/rules/resolve.js +16 -16
- package/dist/esm/tx/rules/resolve.js.map +2 -2
- package/dist/esm/tx/transfer-policy.d.ts +7 -7
- package/dist/esm/tx/transfer-policy.js +1 -1
- package/dist/esm/tx/transfer-policy.js.map +1 -1
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/kiosk.d.ts +2 -2
- package/dist/esm/types/kiosk.js.map +1 -1
- package/dist/esm/types/transfer-policy.d.ts +5 -3
- package/dist/esm/types/transfer-policy.js.map +1 -1
- package/dist/esm/utils.d.ts +1 -1
- package/dist/esm/utils.js +9 -4
- package/dist/esm/utils.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/bcs.ts +18 -20
- package/src/client/kiosk-client.ts +1 -1
- package/src/client/kiosk-transaction.ts +50 -60
- package/src/client/tp-transaction.ts +29 -22
- package/src/query/kiosk.ts +2 -2
- package/src/query/transfer-policy.ts +6 -4
- package/src/tx/kiosk.ts +16 -16
- package/src/tx/personal-kiosk.ts +3 -3
- package/src/tx/rules/attach.ts +5 -5
- package/src/tx/rules/resolve.ts +16 -16
- package/src/tx/transfer-policy.ts +9 -9
- package/src/types/index.ts +2 -2
- package/src/types/kiosk.ts +2 -2
- package/src/types/transfer-policy.ts +5 -3
- package/src/utils.ts +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @mysten/kiosk
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a92b03de42: The Typescript SDK has been renamed to `@mysten/sui` and includes many new features and breaking changes.
|
|
8
|
+
See the [full migration guide](https://sdk.mystenlabs.com/typescript/migrations/sui-1.0) for details on how to upgrade.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [ebdfe7cf21]
|
|
13
|
+
- Updated dependencies [a92b03de42]
|
|
14
|
+
- @mysten/sui@1.0.0
|
|
15
|
+
|
|
3
16
|
## 0.8.10
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/cjs/bcs.d.ts
CHANGED
|
@@ -1,2 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const KioskType: import("@mysten/sui/bcs").BcsType<{
|
|
2
|
+
id: string;
|
|
3
|
+
profits: string;
|
|
4
|
+
owner: string;
|
|
5
|
+
itemCount: number;
|
|
6
|
+
allowExtensions: boolean;
|
|
7
|
+
}, {
|
|
8
|
+
id: string | Uint8Array;
|
|
9
|
+
profits: string | number | bigint;
|
|
10
|
+
owner: string | Uint8Array;
|
|
11
|
+
itemCount: number;
|
|
12
|
+
allowExtensions: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const KioskPurchaseCap: import("@mysten/sui/bcs").BcsType<{
|
|
15
|
+
id: string;
|
|
16
|
+
kioskId: string;
|
|
17
|
+
itemId: string;
|
|
18
|
+
minPrice: string;
|
|
19
|
+
}, {
|
|
20
|
+
id: string | Uint8Array;
|
|
21
|
+
kioskId: string | Uint8Array;
|
|
22
|
+
itemId: string | Uint8Array;
|
|
23
|
+
minPrice: string | number | bigint;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const TransferPolicyCreatedEvent: import("@mysten/sui/bcs").BcsType<{
|
|
26
|
+
id: string;
|
|
27
|
+
}, {
|
|
28
|
+
id: string | Uint8Array;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const TransferPolicyType: import("@mysten/sui/bcs").BcsType<{
|
|
31
|
+
id: string;
|
|
32
|
+
balance: string;
|
|
33
|
+
rules: string[];
|
|
34
|
+
}, {
|
|
35
|
+
id: string | Uint8Array;
|
|
36
|
+
balance: string | number | bigint;
|
|
37
|
+
rules: Iterable<string> & {
|
|
38
|
+
length: number;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
package/dist/cjs/bcs.js
CHANGED
|
@@ -18,30 +18,33 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var bcs_exports = {};
|
|
20
20
|
__export(bcs_exports, {
|
|
21
|
-
|
|
21
|
+
KioskPurchaseCap: () => KioskPurchaseCap,
|
|
22
|
+
KioskType: () => KioskType,
|
|
23
|
+
TransferPolicyCreatedEvent: () => TransferPolicyCreatedEvent,
|
|
24
|
+
TransferPolicyType: () => TransferPolicyType
|
|
22
25
|
});
|
|
23
26
|
module.exports = __toCommonJS(bcs_exports);
|
|
24
|
-
var import_bcs = require("@mysten/sui
|
|
27
|
+
var import_bcs = require("@mysten/sui/bcs");
|
|
25
28
|
var import_types = require("./types/index.js");
|
|
26
|
-
import_bcs.bcs.
|
|
27
|
-
id:
|
|
28
|
-
profits:
|
|
29
|
-
owner:
|
|
30
|
-
itemCount:
|
|
31
|
-
allowExtensions:
|
|
29
|
+
const KioskType = import_bcs.bcs.struct(import_types.KIOSK_TYPE, {
|
|
30
|
+
id: import_bcs.bcs.Address,
|
|
31
|
+
profits: import_bcs.bcs.u64(),
|
|
32
|
+
owner: import_bcs.bcs.Address,
|
|
33
|
+
itemCount: import_bcs.bcs.u32(),
|
|
34
|
+
allowExtensions: import_bcs.bcs.bool()
|
|
32
35
|
});
|
|
33
|
-
import_bcs.bcs.
|
|
34
|
-
id:
|
|
35
|
-
kioskId:
|
|
36
|
-
itemId:
|
|
37
|
-
minPrice:
|
|
36
|
+
const KioskPurchaseCap = import_bcs.bcs.struct(import_types.KIOSK_PURCHASE_CAP, {
|
|
37
|
+
id: import_bcs.bcs.Address,
|
|
38
|
+
kioskId: import_bcs.bcs.Address,
|
|
39
|
+
itemId: import_bcs.bcs.Address,
|
|
40
|
+
minPrice: import_bcs.bcs.u64()
|
|
38
41
|
});
|
|
39
|
-
import_bcs.bcs.
|
|
40
|
-
id:
|
|
42
|
+
const TransferPolicyCreatedEvent = import_bcs.bcs.struct(import_types.TRANSFER_POLICY_CREATED_EVENT, {
|
|
43
|
+
id: import_bcs.bcs.Address
|
|
41
44
|
});
|
|
42
|
-
import_bcs.bcs.
|
|
43
|
-
id:
|
|
44
|
-
balance:
|
|
45
|
-
rules:
|
|
45
|
+
const TransferPolicyType = import_bcs.bcs.struct(import_types.TRANSFER_POLICY_TYPE, {
|
|
46
|
+
id: import_bcs.bcs.Address,
|
|
47
|
+
balance: import_bcs.bcs.u64(),
|
|
48
|
+
rules: import_bcs.bcs.vector(import_bcs.bcs.string())
|
|
46
49
|
});
|
|
47
50
|
//# sourceMappingURL=bcs.js.map
|
package/dist/cjs/bcs.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/bcs.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AAEpB,mBAKO;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\n\nimport {\n\tKIOSK_PURCHASE_CAP,\n\tKIOSK_TYPE,\n\tTRANSFER_POLICY_CREATED_EVENT,\n\tTRANSFER_POLICY_TYPE,\n} from './types/index.js';\n\n// Register the `Kiosk` struct for faster queries.\nexport const KioskType = bcs.struct(KIOSK_TYPE, {\n\tid: bcs.Address,\n\tprofits: bcs.u64(),\n\towner: bcs.Address,\n\titemCount: bcs.u32(),\n\tallowExtensions: bcs.bool(),\n});\n\n// Register the `PurchaseCap` for faster queries.\nexport const KioskPurchaseCap = bcs.struct(KIOSK_PURCHASE_CAP, {\n\tid: bcs.Address,\n\tkioskId: bcs.Address,\n\titemId: bcs.Address,\n\tminPrice: bcs.u64(),\n});\n\n// Register the `TransferPolicyCreated` event data.\nexport const TransferPolicyCreatedEvent = bcs.struct(TRANSFER_POLICY_CREATED_EVENT, {\n\tid: bcs.Address,\n});\n\nexport const TransferPolicyType = bcs.struct(TRANSFER_POLICY_TYPE, {\n\tid: bcs.Address,\n\tbalance: bcs.u64(),\n\trules: bcs.vector(bcs.string()),\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AAEpB,mBAKO;AAGA,MAAM,YAAY,eAAI,OAAO,yBAAY;AAAA,EAC/C,IAAI,eAAI;AAAA,EACR,SAAS,eAAI,IAAI;AAAA,EACjB,OAAO,eAAI;AAAA,EACX,WAAW,eAAI,IAAI;AAAA,EACnB,iBAAiB,eAAI,KAAK;AAC3B,CAAC;AAGM,MAAM,mBAAmB,eAAI,OAAO,iCAAoB;AAAA,EAC9D,IAAI,eAAI;AAAA,EACR,SAAS,eAAI;AAAA,EACb,QAAQ,eAAI;AAAA,EACZ,UAAU,eAAI,IAAI;AACnB,CAAC;AAGM,MAAM,6BAA6B,eAAI,OAAO,4CAA+B;AAAA,EACnF,IAAI,eAAI;AACT,CAAC;AAEM,MAAM,qBAAqB,eAAI,OAAO,mCAAsB;AAAA,EAClE,IAAI,eAAI;AAAA,EACR,SAAS,eAAI,IAAI;AAAA,EACjB,OAAO,eAAI,OAAO,eAAI,OAAO,CAAC;AAC/B,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PaginationArguments, SuiClient } from '@mysten/sui
|
|
1
|
+
import type { PaginationArguments, SuiClient } from '@mysten/sui/client';
|
|
2
2
|
import type { BaseRulePackageIds, TransferPolicyRule } from '../constants.js';
|
|
3
3
|
import { Network } from '../types/index.js';
|
|
4
4
|
import type { FetchKioskOptions, KioskClientOptions, KioskData, OwnedKiosks } from '../types/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/client/kiosk-client.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PaginationArguments, SuiClient } from '@mysten/sui
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { PaginationArguments, SuiClient } from '@mysten/sui/client';\n\nimport {\n\tFLOOR_PRICE_RULE_ADDRESS,\n\tgetBaseRules,\n\tKIOSK_LOCK_RULE_ADDRESS,\n\tPERSONAL_KIOSK_RULE_ADDRESS,\n\tROYALTY_RULE_ADDRESS,\n\trules,\n} from '../constants.js';\nimport type { BaseRulePackageIds, TransferPolicyRule } from '../constants.js';\nimport { fetchKiosk, fetchKioskExtension, getOwnedKiosks } from '../query/kiosk.js';\nimport {\n\tqueryOwnedTransferPolicies,\n\tqueryTransferPolicy,\n\tqueryTransferPolicyCapsByType,\n} from '../query/transfer-policy.js';\nimport { Network } from '../types/index.js';\nimport type {\n\tFetchKioskOptions,\n\tKioskClientOptions,\n\tKioskData,\n\tOwnedKiosks,\n} from '../types/index.js';\n\n/**\n * A Client that allows you to interact with kiosk.\n * Offers utilities to query kiosk, craft transactions to edit your own kiosk,\n * purchase, manage transfer policies, create new kiosks etc.\n * If you pass packageIds, all functionality will be managed using these packages.\n */\nexport class KioskClient {\n\tclient: SuiClient;\n\tnetwork: Network;\n\trules: TransferPolicyRule[];\n\tpackageIds?: BaseRulePackageIds;\n\n\tconstructor(options: KioskClientOptions) {\n\t\tthis.client = options.client;\n\t\tthis.network = options.network;\n\t\tthis.rules = rules; // add all the default rules.\n\t\tthis.packageIds = options.packageIds;\n\n\t\t// Add the custom Package Ids too on the rule list.\n\t\t// Only adds the rules that are passed in the packageId object.\n\t\tif (options.packageIds) this.rules.push(...getBaseRules(options.packageIds));\n\t}\n\n\t/// Querying\n\n\t/**\n\t * Get an addresses's owned kiosks.\n\t * @param address The address for which we want to retrieve the kiosks.\n\t * @param pagination Optional pagination arguments.\n\t * @returns An Object containing all the `kioskOwnerCap` objects as well as the kioskIds.\n\t */\n\tasync getOwnedKiosks({\n\t\taddress,\n\t\tpagination,\n\t}: {\n\t\taddress: string;\n\t\tpagination?: PaginationArguments<string>;\n\t}): Promise<OwnedKiosks> {\n\t\tconst personalPackageId =\n\t\t\tthis.packageIds?.personalKioskRulePackageId || PERSONAL_KIOSK_RULE_ADDRESS[this.network];\n\n\t\treturn getOwnedKiosks(this.client, address, {\n\t\t\tpagination,\n\t\t\tpersonalKioskType: personalPackageId\n\t\t\t\t? `${personalPackageId}::personal_kiosk::PersonalKioskCap`\n\t\t\t\t: '',\n\t\t});\n\t}\n\n\t/**\n\t * Fetches the kiosk contents.\n\t * @param kioskId The ID of the kiosk to fetch.\n\t * @param options Optioal\n\t * @returns\n\t */\n\tasync getKiosk({ id, options }: { id: string; options?: FetchKioskOptions }): Promise<KioskData> {\n\t\treturn (\n\t\t\tawait fetchKiosk(\n\t\t\t\tthis.client,\n\t\t\t\tid,\n\t\t\t\t{\n\t\t\t\t\tlimit: 1000,\n\t\t\t\t},\n\t\t\t\toptions || {},\n\t\t\t)\n\t\t).data;\n\t}\n\n\t/**\n\t * Fetch the extension data (if any) for a kiosk, by type\n\t * @param kioskId The ID of the kiosk to lookup\n\t * @param extensionType The Type of the extension (can be used from by using the type returned by `getKiosk()`)\n\t */\n\tasync getKioskExtension({ kioskId, type }: { kioskId: string; type: string }) {\n\t\treturn fetchKioskExtension(this.client, kioskId, type);\n\t}\n\n\t/**\n\t * Query the Transfer Policy(ies) for type `T`.\n\t * @param type The Type we're querying for (E.g `0xMyAddress::hero::Hero`)\n\t */\n\tasync getTransferPolicies({ type }: { type: string }) {\n\t\treturn queryTransferPolicy(this.client, type);\n\t}\n\n\t/**\n\t * Query all the owned transfer policies for an address.\n\t * Returns `TransferPolicyCap` which uncludes `policyId, policyCapId, type`.\n\t * @param address The address we're searching the owned transfer policies for.\n\t */\n\tasync getOwnedTransferPolicies({ address }: { address: string }) {\n\t\treturn queryOwnedTransferPolicies(this.client, address);\n\t}\n\n\t/**\n\t * Query the Transfer Policy Cap for type `T`, owned by `address`\n\t * @param type The Type `T` for the object\n\t * @param address The address that owns the cap.\n\t */\n\tasync getOwnedTransferPoliciesByType({ type, address }: { type: string; address: string }) {\n\t\treturn queryTransferPolicyCapsByType(this.client, address, type);\n\t}\n\n\t// Someone would just have to create a `kiosk-client.ts` file in their project, initialize a KioskClient\n\t// and call the `addRuleResolver` function. Each rule has a `resolve` function.\n\t// The resolve function is automatically called on `purchaseAndResolve` function call.\n\taddRuleResolver(rule: TransferPolicyRule) {\n\t\tif (this.rules.find((x) => x.rule === rule.rule))\n\t\t\tthrow new Error(`Rule ${rule.rule} resolver already exists.`);\n\t\tthis.rules.push(rule);\n\t}\n\n\t/**\n\t * A convenient helper to get the packageIds for our supported ruleset,\n\t * based on `kioskClient` configuration.\n\t */\n\tgetRulePackageId(\n\t\trule:\n\t\t\t| 'kioskLockRulePackageId'\n\t\t\t| 'royaltyRulePackageId'\n\t\t\t| 'personalKioskRulePackageId'\n\t\t\t| 'floorPriceRulePackageId',\n\t) {\n\t\tconst rules = this.packageIds || {};\n\t\tconst network = this.network;\n\n\t\t/// Check existence of rule based on network and throw an error if it's not found.\n\t\t/// We always have a fallback for testnet or mainnet.\n\t\tif (!rules[rule] && network !== Network.MAINNET && network !== Network.TESTNET) {\n\t\t\tthrow new Error(`Missing packageId for rule ${rule}`);\n\t\t}\n\n\t\tswitch (rule) {\n\t\t\tcase 'kioskLockRulePackageId':\n\t\t\t\treturn rules[rule] || KIOSK_LOCK_RULE_ADDRESS[network];\n\t\t\tcase 'royaltyRulePackageId':\n\t\t\t\treturn rules[rule] || ROYALTY_RULE_ADDRESS[network];\n\t\t\tcase 'personalKioskRulePackageId':\n\t\t\t\treturn rules[rule] || PERSONAL_KIOSK_RULE_ADDRESS[network];\n\t\t\tcase 'floorPriceRulePackageId':\n\t\t\t\treturn rules[rule] || FLOOR_PRICE_RULE_ADDRESS[network];\n\t\t}\n\t}\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,uBAOO;AAEP,mBAAgE;AAChE,6BAIO;AACP,mBAAwB;AAcjB,MAAM,YAAY;AAAA,EAMxB,YAAY,SAA6B;AACxC,SAAK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AA,EAKA,gBAAgB,MAA0B;AACzC,QAAI,KAAK,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI;AAC9C,YAAM,IAAI,MAAM,QAAQ,KAAK,+BAA+B;AAC7D,SAAK,MAAM,KAAK,IAAI;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,iBACC,MAKC;AACD,UAAMA,SAAQ,KAAK,cAAc,CAAC;AAClC,UAAM,UAAU,KAAK;AAIrB,QAAI,CAACA,OAAM,IAAI,KAAK,YAAY,qBAAQ,WAAW,YAAY,qBAAQ,SAAS;AAC/E,YAAM,IAAI,MAAM,8BAA8B,MAAM;AAAA,IACrD;AAEA,YAAQ,MAAM;AAAA,MACb,KAAK;AACJ,eAAOA,OAAM,IAAI,KAAK,yCAAwB,OAAO;AAAA,MACtD,KAAK;AACJ,eAAOA,OAAM,IAAI,KAAK,sCAAqB,OAAO;AAAA,MACnD,KAAK;AACJ,eAAOA,OAAM,IAAI,KAAK,6CAA4B,OAAO;AAAA,MAC1D,KAAK;AACJ,eAAOA,OAAM,IAAI,KAAK,0CAAyB,OAAO;AAAA,IACxD;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["rules"]
|
|
7
7
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Transaction, TransactionArgument, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
2
2
|
import type { ItemId, ItemReference, ItemValue, KioskOwnerCap, ObjectArgument, Price, PurchaseOptions } from '../types/index.js';
|
|
3
3
|
import type { KioskClient } from './kiosk-client.js';
|
|
4
4
|
export type KioskTransactionParams = {
|
|
5
|
-
/** The
|
|
6
|
-
|
|
5
|
+
/** The Transaction for this run */
|
|
6
|
+
transaction: Transaction;
|
|
7
|
+
/** @deprecated use transaction instead */
|
|
8
|
+
transactionBlock?: Transaction;
|
|
7
9
|
/**
|
|
8
10
|
* You can create a new KioskClient by calling `new KioskClient()`
|
|
9
11
|
*/
|
|
@@ -20,11 +22,11 @@ export type KioskTransactionParams = {
|
|
|
20
22
|
*/
|
|
21
23
|
export declare class KioskTransaction {
|
|
22
24
|
#private;
|
|
23
|
-
|
|
25
|
+
transaction: Transaction;
|
|
24
26
|
kioskClient: KioskClient;
|
|
25
27
|
kiosk?: TransactionObjectArgument;
|
|
26
28
|
kioskCap?: TransactionObjectArgument;
|
|
27
|
-
constructor({ transactionBlock, kioskClient, cap }: KioskTransactionParams);
|
|
29
|
+
constructor({ transactionBlock, transaction, kioskClient, cap, }: KioskTransactionParams);
|
|
28
30
|
/**
|
|
29
31
|
* Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.
|
|
30
32
|
* Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.
|
|
@@ -172,7 +174,7 @@ export declare class KioskTransaction {
|
|
|
172
174
|
*/
|
|
173
175
|
setCap(cap: KioskOwnerCap): this | undefined;
|
|
174
176
|
/**
|
|
175
|
-
* A function that ends up the kiosk building
|
|
177
|
+
* A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
|
|
176
178
|
* `PersonalKioskCap`, in case we are operating on a personal kiosk.
|
|
177
179
|
* It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
|
|
178
180
|
*/
|
|
@@ -59,7 +59,12 @@ var import_transfer_policy = require("../tx/transfer-policy.js");
|
|
|
59
59
|
var import_utils = require("../utils.js");
|
|
60
60
|
var _pendingShare, _pendingTransfer, _promise, _personalCap, _finalized, _borrowFromPersonalCap, borrowFromPersonalCap_fn, _setPendingStatuses, setPendingStatuses_fn, _validateKioskIsSet, validateKioskIsSet_fn, _validateFinalizedStatus, validateFinalizedStatus_fn;
|
|
61
61
|
class KioskTransaction {
|
|
62
|
-
constructor({
|
|
62
|
+
constructor({
|
|
63
|
+
transactionBlock,
|
|
64
|
+
transaction = transactionBlock,
|
|
65
|
+
kioskClient,
|
|
66
|
+
cap
|
|
67
|
+
}) {
|
|
63
68
|
/**
|
|
64
69
|
* A function to borrow from `personalCap`.
|
|
65
70
|
*/
|
|
@@ -78,7 +83,7 @@ class KioskTransaction {
|
|
|
78
83
|
__privateAdd(this, _personalCap, void 0);
|
|
79
84
|
// A flag that checks whether kiosk TX is finalized.
|
|
80
85
|
__privateAdd(this, _finalized, false);
|
|
81
|
-
this.
|
|
86
|
+
this.transaction = transaction;
|
|
82
87
|
this.kioskClient = kioskClient;
|
|
83
88
|
if (cap)
|
|
84
89
|
this.setCap(cap);
|
|
@@ -94,7 +99,7 @@ class KioskTransaction {
|
|
|
94
99
|
share: true,
|
|
95
100
|
transfer: true
|
|
96
101
|
});
|
|
97
|
-
const [kiosk, cap] = kioskTx.createKiosk(this.
|
|
102
|
+
const [kiosk, cap] = kioskTx.createKiosk(this.transaction);
|
|
98
103
|
this.kiosk = kiosk;
|
|
99
104
|
this.kioskCap = cap;
|
|
100
105
|
return this;
|
|
@@ -115,7 +120,7 @@ class KioskTransaction {
|
|
|
115
120
|
convertToPersonal(borrow) {
|
|
116
121
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
117
122
|
const cap = (0, import_personal_kiosk.convertToPersonalTx)(
|
|
118
|
-
this.
|
|
123
|
+
this.transaction,
|
|
119
124
|
this.kiosk,
|
|
120
125
|
this.kioskCap,
|
|
121
126
|
this.kioskClient.getRulePackageId("personalKioskRulePackageId")
|
|
@@ -132,8 +137,8 @@ class KioskTransaction {
|
|
|
132
137
|
*/
|
|
133
138
|
createAndShare(address) {
|
|
134
139
|
__privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
|
|
135
|
-
const cap = kioskTx.createKioskAndShare(this.
|
|
136
|
-
this.
|
|
140
|
+
const cap = kioskTx.createKioskAndShare(this.transaction);
|
|
141
|
+
this.transaction.transferObjects([cap], this.transaction.pure.address(address));
|
|
137
142
|
}
|
|
138
143
|
/**
|
|
139
144
|
* Shares the kiosk.
|
|
@@ -141,7 +146,7 @@ class KioskTransaction {
|
|
|
141
146
|
share() {
|
|
142
147
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
143
148
|
__privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { share: false });
|
|
144
|
-
kioskTx.shareKiosk(this.
|
|
149
|
+
kioskTx.shareKiosk(this.transaction, this.kiosk);
|
|
145
150
|
}
|
|
146
151
|
/**
|
|
147
152
|
* Should be called only after `create` is called.
|
|
@@ -152,10 +157,7 @@ class KioskTransaction {
|
|
|
152
157
|
throw new Error("You can only call `shareAndTransferCap` on a non-personal kiosk.");
|
|
153
158
|
__privateMethod(this, _setPendingStatuses, setPendingStatuses_fn).call(this, { transfer: false });
|
|
154
159
|
this.share();
|
|
155
|
-
this.
|
|
156
|
-
[this.kioskCap],
|
|
157
|
-
this.transactionBlock.pure.address(address)
|
|
158
|
-
);
|
|
160
|
+
this.transaction.transferObjects([this.kioskCap], this.transaction.pure.address(address));
|
|
159
161
|
}
|
|
160
162
|
/**
|
|
161
163
|
* A function to borrow an item from a kiosk & execute any function with it.
|
|
@@ -164,7 +166,7 @@ class KioskTransaction {
|
|
|
164
166
|
borrowTx({ itemType, itemId }, callback) {
|
|
165
167
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
166
168
|
const [itemObj, promise] = kioskTx.borrowValue(
|
|
167
|
-
this.
|
|
169
|
+
this.transaction,
|
|
168
170
|
itemType,
|
|
169
171
|
this.kiosk,
|
|
170
172
|
this.kioskCap,
|
|
@@ -182,7 +184,7 @@ class KioskTransaction {
|
|
|
182
184
|
borrow({ itemType, itemId }) {
|
|
183
185
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
184
186
|
const [itemObj, promise] = kioskTx.borrowValue(
|
|
185
|
-
this.
|
|
187
|
+
this.transaction,
|
|
186
188
|
itemType,
|
|
187
189
|
this.kiosk,
|
|
188
190
|
this.kioskCap,
|
|
@@ -196,7 +198,7 @@ class KioskTransaction {
|
|
|
196
198
|
*/
|
|
197
199
|
return({ itemType, item, promise }) {
|
|
198
200
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
199
|
-
kioskTx.returnValue(this.
|
|
201
|
+
kioskTx.returnValue(this.transaction, itemType, this.kiosk, item, promise);
|
|
200
202
|
return this;
|
|
201
203
|
}
|
|
202
204
|
/**
|
|
@@ -206,13 +208,8 @@ class KioskTransaction {
|
|
|
206
208
|
*/
|
|
207
209
|
withdraw(address, amount) {
|
|
208
210
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
209
|
-
const coin = kioskTx.withdrawFromKiosk(
|
|
210
|
-
|
|
211
|
-
this.kiosk,
|
|
212
|
-
this.kioskCap,
|
|
213
|
-
amount
|
|
214
|
-
);
|
|
215
|
-
this.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));
|
|
211
|
+
const coin = kioskTx.withdrawFromKiosk(this.transaction, this.kiosk, this.kioskCap, amount);
|
|
212
|
+
this.transaction.transferObjects([coin], this.transaction.pure.address(address));
|
|
216
213
|
return this;
|
|
217
214
|
}
|
|
218
215
|
/**
|
|
@@ -222,7 +219,7 @@ class KioskTransaction {
|
|
|
222
219
|
*/
|
|
223
220
|
place({ itemType, item }) {
|
|
224
221
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
225
|
-
kioskTx.place(this.
|
|
222
|
+
kioskTx.place(this.transaction, itemType, this.kiosk, this.kioskCap, item);
|
|
226
223
|
return this;
|
|
227
224
|
}
|
|
228
225
|
/**
|
|
@@ -233,7 +230,7 @@ class KioskTransaction {
|
|
|
233
230
|
*/
|
|
234
231
|
placeAndList({ itemType, item, price }) {
|
|
235
232
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
236
|
-
kioskTx.placeAndList(this.
|
|
233
|
+
kioskTx.placeAndList(this.transaction, itemType, this.kiosk, this.kioskCap, item, price);
|
|
237
234
|
return this;
|
|
238
235
|
}
|
|
239
236
|
/**
|
|
@@ -244,7 +241,7 @@ class KioskTransaction {
|
|
|
244
241
|
*/
|
|
245
242
|
list({ itemType, itemId, price }) {
|
|
246
243
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
247
|
-
kioskTx.list(this.
|
|
244
|
+
kioskTx.list(this.transaction, itemType, this.kiosk, this.kioskCap, itemId, price);
|
|
248
245
|
return this;
|
|
249
246
|
}
|
|
250
247
|
/**
|
|
@@ -254,7 +251,7 @@ class KioskTransaction {
|
|
|
254
251
|
*/
|
|
255
252
|
delist({ itemType, itemId }) {
|
|
256
253
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
257
|
-
kioskTx.delist(this.
|
|
254
|
+
kioskTx.delist(this.transaction, itemType, this.kiosk, this.kioskCap, itemId);
|
|
258
255
|
return this;
|
|
259
256
|
}
|
|
260
257
|
/**
|
|
@@ -265,7 +262,7 @@ class KioskTransaction {
|
|
|
265
262
|
*/
|
|
266
263
|
take({ itemType, itemId }) {
|
|
267
264
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
268
|
-
return kioskTx.take(this.
|
|
265
|
+
return kioskTx.take(this.transaction, itemType, this.kiosk, this.kioskCap, itemId);
|
|
269
266
|
}
|
|
270
267
|
/**
|
|
271
268
|
* Transfer a non-locked/non-listed item to an address.
|
|
@@ -277,7 +274,7 @@ class KioskTransaction {
|
|
|
277
274
|
transfer({ itemType, itemId, address }) {
|
|
278
275
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
279
276
|
const item = this.take({ itemType, itemId });
|
|
280
|
-
this.
|
|
277
|
+
this.transaction.transferObjects([item], this.transaction.pure.address(address));
|
|
281
278
|
return this;
|
|
282
279
|
}
|
|
283
280
|
/**
|
|
@@ -295,14 +292,7 @@ class KioskTransaction {
|
|
|
295
292
|
policy
|
|
296
293
|
}) {
|
|
297
294
|
__privateMethod(this, _validateKioskIsSet, validateKioskIsSet_fn).call(this);
|
|
298
|
-
kioskTx.lock(
|
|
299
|
-
this.transactionBlock,
|
|
300
|
-
itemType,
|
|
301
|
-
this.kiosk,
|
|
302
|
-
this.kioskCap,
|
|
303
|
-
policy,
|
|
304
|
-
itemId ?? item
|
|
305
|
-
);
|
|
295
|
+
kioskTx.lock(this.transaction, itemType, this.kiosk, this.kioskCap, policy, itemId ?? item);
|
|
306
296
|
return this;
|
|
307
297
|
}
|
|
308
298
|
/**
|
|
@@ -320,10 +310,10 @@ class KioskTransaction {
|
|
|
320
310
|
price,
|
|
321
311
|
sellerKiosk
|
|
322
312
|
}) {
|
|
323
|
-
const coin = this.
|
|
324
|
-
this.
|
|
313
|
+
const coin = this.transaction.splitCoins(this.transaction.gas, [
|
|
314
|
+
this.transaction.pure.u64(price)
|
|
325
315
|
]);
|
|
326
|
-
return kioskTx.purchase(this.
|
|
316
|
+
return kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);
|
|
327
317
|
}
|
|
328
318
|
/**
|
|
329
319
|
* A function to purchase and resolve a transfer policy.
|
|
@@ -367,7 +357,8 @@ class KioskTransaction {
|
|
|
367
357
|
canTransferOutsideKiosk = false;
|
|
368
358
|
ruleDefinition.resolveRuleFunction({
|
|
369
359
|
packageId: ruleDefinition.packageId,
|
|
370
|
-
transactionBlock: this.
|
|
360
|
+
transactionBlock: this.transaction,
|
|
361
|
+
transaction: this.transaction,
|
|
371
362
|
itemType,
|
|
372
363
|
itemId,
|
|
373
364
|
price: price.toString(),
|
|
@@ -380,7 +371,7 @@ class KioskTransaction {
|
|
|
380
371
|
extraArgs: extraArgs || {}
|
|
381
372
|
});
|
|
382
373
|
}
|
|
383
|
-
(0, import_transfer_policy.confirmRequest)(this.
|
|
374
|
+
(0, import_transfer_policy.confirmRequest)(this.transaction, itemType, policy.id, transferRequest);
|
|
384
375
|
if (canTransferOutsideKiosk)
|
|
385
376
|
this.place({ itemType, item: purchasedItem });
|
|
386
377
|
return this;
|
|
@@ -392,15 +383,15 @@ class KioskTransaction {
|
|
|
392
383
|
*/
|
|
393
384
|
setCap(cap) {
|
|
394
385
|
__privateMethod(this, _validateFinalizedStatus, validateFinalizedStatus_fn).call(this);
|
|
395
|
-
this.kiosk = this.
|
|
386
|
+
this.kiosk = this.transaction.object(cap.kioskId);
|
|
396
387
|
if (!cap.isPersonal) {
|
|
397
|
-
this.kioskCap = this.
|
|
388
|
+
this.kioskCap = this.transaction.object(cap.objectId);
|
|
398
389
|
return;
|
|
399
390
|
}
|
|
400
391
|
return __privateMethod(this, _borrowFromPersonalCap, borrowFromPersonalCap_fn).call(this, cap.objectId);
|
|
401
392
|
}
|
|
402
393
|
/**
|
|
403
|
-
* A function that ends up the kiosk building
|
|
394
|
+
* A function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the
|
|
404
395
|
* `PersonalKioskCap`, in case we are operating on a personal kiosk.
|
|
405
396
|
* It will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.
|
|
406
397
|
*/
|
|
@@ -417,17 +408,13 @@ class KioskTransaction {
|
|
|
417
408
|
}
|
|
418
409
|
const packageId = this.kioskClient.getRulePackageId("personalKioskRulePackageId");
|
|
419
410
|
if (__privateGet(this, _promise)) {
|
|
420
|
-
this.
|
|
411
|
+
this.transaction.moveCall({
|
|
421
412
|
target: `${packageId}::personal_kiosk::return_val`,
|
|
422
|
-
arguments: [
|
|
423
|
-
__privateGet(this, _personalCap),
|
|
424
|
-
this.transactionBlock.object(this.kioskCap),
|
|
425
|
-
__privateGet(this, _promise)
|
|
426
|
-
]
|
|
413
|
+
arguments: [__privateGet(this, _personalCap), this.transaction.object(this.kioskCap), __privateGet(this, _promise)]
|
|
427
414
|
});
|
|
428
415
|
}
|
|
429
416
|
if (__privateGet(this, _pendingTransfer))
|
|
430
|
-
(0, import_personal_kiosk.transferPersonalCapTx)(this.
|
|
417
|
+
(0, import_personal_kiosk.transferPersonalCapTx)(this.transaction, __privateGet(this, _personalCap), packageId);
|
|
431
418
|
__privateSet(this, _finalized, true);
|
|
432
419
|
}
|
|
433
420
|
// Some setters in case we want custom behavior.
|
|
@@ -468,14 +455,14 @@ _personalCap = new WeakMap();
|
|
|
468
455
|
_finalized = new WeakMap();
|
|
469
456
|
_borrowFromPersonalCap = new WeakSet();
|
|
470
457
|
borrowFromPersonalCap_fn = function(personalCap) {
|
|
471
|
-
const [kioskCap, promise] = this.
|
|
458
|
+
const [kioskCap, promise] = this.transaction.moveCall({
|
|
472
459
|
target: `${this.kioskClient.getRulePackageId(
|
|
473
460
|
"personalKioskRulePackageId"
|
|
474
461
|
)}::personal_kiosk::borrow_val`,
|
|
475
|
-
arguments: [this.
|
|
462
|
+
arguments: [this.transaction.object(personalCap)]
|
|
476
463
|
});
|
|
477
464
|
this.kioskCap = kioskCap;
|
|
478
|
-
__privateSet(this, _personalCap, this.
|
|
465
|
+
__privateSet(this, _personalCap, this.transaction.object(personalCap));
|
|
479
466
|
__privateSet(this, _promise, promise);
|
|
480
467
|
return this;
|
|
481
468
|
};
|
|
@@ -497,6 +484,6 @@ validateKioskIsSet_fn = function() {
|
|
|
497
484
|
_validateFinalizedStatus = new WeakSet();
|
|
498
485
|
validateFinalizedStatus_fn = function() {
|
|
499
486
|
if (__privateGet(this, _finalized))
|
|
500
|
-
throw new Error("You can't add more transactions to a finalized kiosk transaction
|
|
487
|
+
throw new Error("You can't add more transactions to a finalized kiosk transaction.");
|
|
501
488
|
};
|
|
502
489
|
//# sourceMappingURL=kiosk-transaction.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/client/kiosk-transaction.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tTransactionArgument,\n\tTransactionBlock,\n\tTransactionObjectArgument,\n} from '@mysten/sui.js/transactions';\n\nimport * as kioskTx from '../tx/kiosk.js';\nimport { convertToPersonalTx, transferPersonalCapTx } from '../tx/personal-kiosk.js';\nimport { confirmRequest } from '../tx/transfer-policy.js';\nimport type {\n\tItemId,\n\tItemReference,\n\tItemValue,\n\tKioskOwnerCap,\n\tObjectArgument,\n\tPrice,\n\tPurchaseOptions,\n} from '../types/index.js';\nimport { getNormalizedRuleType } from '../utils.js';\nimport type { KioskClient } from './kiosk-client.js';\n\nexport type KioskTransactionParams = {\n\t/** The TransactionBlock for this run */\n\ttransactionBlock: TransactionBlock;\n\t/**\n\t * You can create a new KioskClient by calling `new KioskClient()`\n\t */\n\tkioskClient: KioskClient;\n\t/**\n\t * You can optionally pass in the `cap` as returned\n\t * from `kioskClient.getOwnedKiosks` when initializing the client\n\t * Otherwise, you can set it by calling `kioskTransaction.setCap()`\n\t */\n\tcap?: KioskOwnerCap;\n};\n\n/**\n * A helper for building transactions that involve kiosk.\n */\nexport class KioskTransaction {\n\ttransactionBlock: TransactionBlock;\n\tkioskClient: KioskClient;\n\tkiosk?: TransactionObjectArgument;\n\tkioskCap?: TransactionObjectArgument;\n\t// If we're pending `share` of a new kiosk, `finalize()` will share it.\n\t#pendingShare?: boolean;\n\t// If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.\n\t#pendingTransfer?: boolean;\n\t// The promise that the personalCap will be returned on `finalize()`.\n\t#promise?: TransactionArgument | undefined;\n\t// The personal kiosk argument.\n\t#personalCap?: TransactionObjectArgument;\n\t// A flag that checks whether kiosk TX is finalized.\n\t#finalized: boolean = false;\n\n\tconstructor({ transactionBlock, kioskClient, cap }: KioskTransactionParams) {\n\t\tthis.transactionBlock = transactionBlock;\n\t\tthis.kioskClient = kioskClient;\n\n\t\tif (cap) this.setCap(cap);\n\t}\n\n\t/**\n\t * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.\n\t * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.\n\t * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n\t */\n\tcreate() {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.#setPendingStatuses({\n\t\t\tshare: true,\n\t\t\ttransfer: true,\n\t\t});\n\t\tconst [kiosk, cap] = kioskTx.createKiosk(this.transactionBlock);\n\t\tthis.kiosk = kiosk;\n\t\tthis.kioskCap = cap;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a personal kiosk & shares it.\n\t * The `PersonalKioskCap` is transferred to the signer.\n\t * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n\t */\n\tcreatePersonal(borrow?: boolean) {\n\t\tthis.#pendingShare = true;\n\t\treturn this.create().convertToPersonal(borrow);\n\t}\n\n\t/**\n\t * Converts a kiosk to a Personal (Soulbound) Kiosk.\n\t * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.\n\t */\n\tconvertToPersonal(borrow?: boolean) {\n\t\tthis.#validateKioskIsSet();\n\n\t\tconst cap = convertToPersonalTx(\n\t\t\tthis.transactionBlock,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\tthis.kioskClient.getRulePackageId('personalKioskRulePackageId'),\n\t\t);\n\n\t\t// if we enable `borrow`, we borrow the kioskCap from the cap.\n\t\tif (borrow) this.#borrowFromPersonalCap(cap);\n\t\telse this.#personalCap = cap;\n\n\t\tthis.#setPendingStatuses({ transfer: true });\n\t\treturn this;\n\t}\n\n\t/**\n\t * Single function way to create a kiosk, share it and transfer the cap to the specified address.\n\t */\n\tcreateAndShare(address: string) {\n\t\tthis.#validateFinalizedStatus();\n\t\tconst cap = kioskTx.createKioskAndShare(this.transactionBlock);\n\t\tthis.transactionBlock.transferObjects([cap], this.transactionBlock.pure.address(address));\n\t}\n\n\t/**\n\t * Shares the kiosk.\n\t */\n\tshare() {\n\t\tthis.#validateKioskIsSet();\n\t\tthis.#setPendingStatuses({ share: false });\n\t\tkioskTx.shareKiosk(this.transactionBlock, this.kiosk!);\n\t}\n\n\t/**\n\t * Should be called only after `create` is called.\n\t * It shares the kiosk & transfers the cap to the specified address.\n\t */\n\tshareAndTransferCap(address: string) {\n\t\tif (this.#personalCap)\n\t\t\tthrow new Error('You can only call `shareAndTransferCap` on a non-personal kiosk.');\n\t\tthis.#setPendingStatuses({ transfer: false });\n\t\tthis.share();\n\t\tthis.transactionBlock.transferObjects(\n\t\t\t[this.kioskCap!],\n\t\t\tthis.transactionBlock.pure.address(address),\n\t\t);\n\t}\n\n\t/**\n\t * A function to borrow an item from a kiosk & execute any function with it.\n\t * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.\n\t */\n\tborrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [itemObj, promise] = kioskTx.borrowValue(\n\t\t\tthis.transactionBlock,\n\t\t\titemType,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\titemId,\n\t\t);\n\n\t\tcallback(itemObj);\n\n\t\tthis.return({ itemType, item: itemObj, promise });\n\t}\n\n\t/**\n\t * Borrows an item from the kiosk.\n\t * This will fail if the item is listed for sale.\n\t *\n\t * Requires calling `return`.\n\t */\n\tborrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument] {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [itemObj, promise] = kioskTx.borrowValue(\n\t\t\tthis.transactionBlock,\n\t\t\titemType,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\titemId,\n\t\t);\n\n\t\treturn [itemObj, promise];\n\t}\n\n\t/**\n\t * Returns the item back to the kiosk.\n\t * Accepts the parameters returned from the `borrow` function.\n\t */\n\treturn({ itemType, item, promise }: ItemValue & { promise: TransactionArgument }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.returnValue(this.transactionBlock, itemType, this.kiosk!, item, promise);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to withdraw from kiosk\n\t * @param address Where to trasnfer the coin.\n\t * @param amount The amount we aim to withdraw.\n\t */\n\twithdraw(address: string, amount?: string | bigint | number) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst coin = kioskTx.withdrawFromKiosk(\n\t\t\tthis.transactionBlock,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\tamount,\n\t\t);\n\t\tthis.transactionBlock.transferObjects([coin], this.transactionBlock.pure.address(address));\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to place an item in the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t */\n\tplace({ itemType, item }: ItemReference) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.place(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, item);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to place an item in the kiosk and list it for sale in one transaction.\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param price The price in MIST\n\t */\n\tplaceAndList({ itemType, item, price }: ItemReference & Price) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.placeAndList(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, item, price);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to list an item in the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param price The price in MIST\n\t */\n\tlist({ itemType, itemId, price }: ItemId & { price: string | bigint }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.list(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId, price);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to delist an item from the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n\tdelist({ itemType, itemId }: ItemId) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.delist(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.\n\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n\ttake({ itemType, itemId }: ItemId): TransactionObjectArgument {\n\t\tthis.#validateKioskIsSet();\n\t\treturn kioskTx.take(this.transactionBlock, itemType, this.kiosk!, this.kioskCap!, itemId);\n\t}\n\n\t/**\n\t * Transfer a non-locked/non-listed item to an address.\n\t *\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param address The destination address\n\t */\n\ttransfer({ itemType, itemId, address }: ItemId & { address: string }) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst item = this.take({ itemType, itemId });\n\t\tthis.transactionBlock.transferObjects([item], this.transactionBlock.pure.address(address));\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to take lock an item in the kiosk.\n\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param itemId The ID of the item - Deprecated: Use `item` instead.\n\t * @param policy The Policy ID or Transaction Argument for item T\n\t */\n\tlock({\n\t\titemType,\n\t\titem,\n\t\titemId,\n\t\tpolicy,\n\t}: ItemReference & { policy: ObjectArgument; itemId?: string }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.lock(\n\t\t\tthis.transactionBlock,\n\t\t\titemType,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\tpolicy,\n\t\t\titemId ?? item,\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Purchase an item from a seller's kiosk.\n\t * Returns [item, transferRequest]\n\t * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param price The price in MIST\n\t * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n\t */\n\tpurchase({\n\t\titemType,\n\t\titemId,\n\t\tprice,\n\t\tsellerKiosk,\n\t}: ItemId & Price & { sellerKiosk: ObjectArgument }): [\n\t\tTransactionObjectArgument,\n\t\tTransactionObjectArgument,\n\t] {\n\t\t// Split the coin for the amount of the listing.\n\t\tconst coin = this.transactionBlock.splitCoins(this.transactionBlock.gas, [\n\t\t\tthis.transactionBlock.pure.u64(price),\n\t\t]);\n\t\treturn kioskTx.purchase(this.transactionBlock, itemType, sellerKiosk, itemId, coin);\n\t}\n\n\t/**\n\t * A function to purchase and resolve a transfer policy.\n\t * If the transfer policy has the `lock` rule, the item is locked in the kiosk.\n\t * Otherwise, the item is placed in the kiosk.\n\t * @param itemType The type of the item\n\t * @param itemId The id of the item\n\t * @param price The price of the specified item\n\t * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n\t * @param extraArgs Used to pass arguments for custom rule resolvers.\n\t */\n\tasync purchaseAndResolve({\n\t\titemType,\n\t\titemId,\n\t\tprice,\n\t\tsellerKiosk,\n\t\textraArgs,\n\t}: ItemId & Price & { sellerKiosk: ObjectArgument } & PurchaseOptions) {\n\t\tthis.#validateKioskIsSet();\n\t\t// Get a list of the transfer policies.\n\t\tconst policies = await this.kioskClient.getTransferPolicies({ type: itemType });\n\n\t\tif (policies.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`The type ${itemType} doesn't have a Transfer Policy so it can't be traded through kiosk.`,\n\t\t\t);\n\t\t}\n\n\t\tconst policy = policies[0]; // we now pick the first one. We need to add an option to define which one.\n\n\t\t// initialize the purchase `kiosk::purchase`\n\t\tconst [purchasedItem, transferRequest] = this.purchase({\n\t\t\titemType,\n\t\t\titemId,\n\t\t\tprice,\n\t\t\tsellerKiosk,\n\t\t});\n\n\t\tlet canTransferOutsideKiosk = true;\n\n\t\tfor (const rule of policy.rules) {\n\t\t\tconst ruleDefinition = this.kioskClient.rules.find(\n\t\t\t\t(x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule),\n\t\t\t);\n\t\t\tif (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);\n\n\t\t\tif (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;\n\n\t\t\truleDefinition.resolveRuleFunction({\n\t\t\t\tpackageId: ruleDefinition.packageId,\n\t\t\t\ttransactionBlock: this.transactionBlock,\n\t\t\t\titemType,\n\t\t\t\titemId,\n\t\t\t\tprice: price.toString(),\n\t\t\t\tsellerKiosk,\n\t\t\t\tpolicyId: policy.id,\n\t\t\t\ttransferRequest,\n\t\t\t\tpurchasedItem,\n\t\t\t\tkiosk: this.kiosk!,\n\t\t\t\tkioskCap: this.kioskCap!,\n\t\t\t\textraArgs: extraArgs || {},\n\t\t\t});\n\t\t}\n\n\t\tconfirmRequest(this.transactionBlock, itemType, policy.id, transferRequest);\n\n\t\tif (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to setup the client using an existing `ownerCap`,\n\t * as return from the `kioskClient.getOwnedKiosks` function.\n\t * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.\n\t */\n\tsetCap(cap: KioskOwnerCap) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kiosk = this.transactionBlock.object(cap.kioskId);\n\t\tif (!cap.isPersonal) {\n\t\t\tthis.kioskCap = this.transactionBlock.object(cap.objectId);\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.#borrowFromPersonalCap(cap.objectId);\n\t}\n\n\t/**\n\t *\tA function that ends up the kiosk building txb & returns the `kioskOwnerCap` back to the\n\t * `PersonalKioskCap`, in case we are operating on a personal kiosk.\n\t * \tIt will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.\n\t */\n\tfinalize() {\n\t\tthis.#validateKioskIsSet();\n\t\t// If we're pending the sharing of the new kiosk, share it.\n\t\tif (this.#pendingShare) this.share();\n\n\t\t// If we're operating on a non-personal kiosk, we don't need to do anything else.\n\t\tif (!this.#personalCap) {\n\t\t\t// If we're pending transfer though, we inform user to call `shareAndTransferCap()`.\n\t\t\tif (this.#pendingTransfer)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'You need to transfer the `kioskOwnerCap` by calling `shareAndTransferCap()` before wrap',\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\n\t\t// if we have a promise, return the `ownerCap` back to the personal cap.\n\t\tif (this.#promise) {\n\t\t\tthis.transactionBlock.moveCall({\n\t\t\t\ttarget: `${packageId}::personal_kiosk::return_val`,\n\t\t\t\targuments: [\n\t\t\t\t\tthis.#personalCap,\n\t\t\t\t\tthis.transactionBlock.object(this.kioskCap!),\n\t\t\t\t\tthis.#promise!,\n\t\t\t\t],\n\t\t\t});\n\t\t}\n\n\t\t// If we are pending transferring the personalCap, we do it here.\n\t\tif (this.#pendingTransfer)\n\t\t\ttransferPersonalCapTx(this.transactionBlock, this.#personalCap, packageId);\n\n\t\t// Mark the transaction block as finalized, so no other functions can be called.\n\t\tthis.#finalized = true;\n\t}\n\n\t// Some setters in case we want custom behavior.\n\tsetKioskCap(cap: TransactionObjectArgument) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kioskCap = cap;\n\t\treturn this;\n\t}\n\n\tsetKiosk(kiosk: TransactionObjectArgument) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kiosk = kiosk;\n\t\treturn this;\n\t}\n\n\t// Some getters\n\t/*\n\t * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.\n\t */\n\tgetKiosk() {\n\t\tthis.#validateFinalizedStatus();\n\t\tif (!this.kiosk) throw new Error('Kiosk is not set.');\n\t\treturn this.kiosk;\n\t}\n\n\t/*\n\t * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.\n\t */\n\tgetKioskCap() {\n\t\tthis.#validateFinalizedStatus();\n\t\tif (!this.kioskCap) throw new Error('Kiosk cap is not set');\n\t\treturn this.kioskCap;\n\t}\n\n\t/**\n\t * A function to borrow from `personalCap`.\n\t */\n\t#borrowFromPersonalCap(personalCap: ObjectArgument) {\n\t\tconst [kioskCap, promise] = this.transactionBlock.moveCall({\n\t\t\ttarget: `${this.kioskClient.getRulePackageId(\n\t\t\t\t'personalKioskRulePackageId',\n\t\t\t)}::personal_kiosk::borrow_val`,\n\t\t\targuments: [this.transactionBlock.object(personalCap)],\n\t\t});\n\n\t\tthis.kioskCap = kioskCap;\n\t\tthis.#personalCap = this.transactionBlock.object(personalCap);\n\t\tthis.#promise = promise;\n\n\t\treturn this;\n\t}\n\n\t#setPendingStatuses({ share, transfer }: { share?: boolean; transfer?: boolean }) {\n\t\tif (transfer !== undefined) this.#pendingTransfer = transfer;\n\t\tif (share !== undefined) this.#pendingShare = share;\n\t}\n\n\t#validateKioskIsSet() {\n\t\tthis.#validateFinalizedStatus();\n\n\t\tif (!this.kiosk || !this.kioskCap)\n\t\t\tthrow new Error(\n\t\t\t\t'You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`',\n\t\t\t);\n\t}\n\n\t// Validates that `finalize`\n\t#validateFinalizedStatus() {\n\t\tif (this.#finalized)\n\t\t\tthrow new Error(\"You can't add more transactions to a finalized kiosk transaction block.\");\n\t}\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,cAAyB;AACzB,4BAA2D;AAC3D,6BAA+B;AAU/B,mBAAsC;AArBtC;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n\tTransaction,\n\tTransactionArgument,\n\tTransactionObjectArgument,\n} from '@mysten/sui/transactions';\n\nimport * as kioskTx from '../tx/kiosk.js';\nimport { convertToPersonalTx, transferPersonalCapTx } from '../tx/personal-kiosk.js';\nimport { confirmRequest } from '../tx/transfer-policy.js';\nimport type {\n\tItemId,\n\tItemReference,\n\tItemValue,\n\tKioskOwnerCap,\n\tObjectArgument,\n\tPrice,\n\tPurchaseOptions,\n} from '../types/index.js';\nimport { getNormalizedRuleType } from '../utils.js';\nimport type { KioskClient } from './kiosk-client.js';\n\nexport type KioskTransactionParams = {\n\t/** The Transaction for this run */\n\ttransaction: Transaction;\n\n\t/** @deprecated use transaction instead */\n\ttransactionBlock?: Transaction;\n\t/**\n\t * You can create a new KioskClient by calling `new KioskClient()`\n\t */\n\tkioskClient: KioskClient;\n\t/**\n\t * You can optionally pass in the `cap` as returned\n\t * from `kioskClient.getOwnedKiosks` when initializing the client\n\t * Otherwise, you can set it by calling `kioskTransaction.setCap()`\n\t */\n\tcap?: KioskOwnerCap;\n};\n\n/**\n * A helper for building transactions that involve kiosk.\n */\nexport class KioskTransaction {\n\ttransaction: Transaction;\n\tkioskClient: KioskClient;\n\tkiosk?: TransactionObjectArgument;\n\tkioskCap?: TransactionObjectArgument;\n\t// If we're pending `share` of a new kiosk, `finalize()` will share it.\n\t#pendingShare?: boolean;\n\t// If we're pending transferring of the cap, `finalize()` will either error or transfer the cap if it's a new personal.\n\t#pendingTransfer?: boolean;\n\t// The promise that the personalCap will be returned on `finalize()`.\n\t#promise?: TransactionArgument | undefined;\n\t// The personal kiosk argument.\n\t#personalCap?: TransactionObjectArgument;\n\t// A flag that checks whether kiosk TX is finalized.\n\t#finalized: boolean = false;\n\n\tconstructor({\n\t\ttransactionBlock,\n\t\ttransaction = transactionBlock!,\n\t\tkioskClient,\n\t\tcap,\n\t}: KioskTransactionParams) {\n\t\tthis.transaction = transaction;\n\t\tthis.kioskClient = kioskClient;\n\n\t\tif (cap) this.setCap(cap);\n\t}\n\n\t/**\n\t * Creates a kiosk and saves `kiosk` and `kioskOwnerCap` in state.\n\t * Helpful if we want to chain some actions before sharing + transferring the cap to the specified address.\n\t * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n\t */\n\tcreate() {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.#setPendingStatuses({\n\t\t\tshare: true,\n\t\t\ttransfer: true,\n\t\t});\n\t\tconst [kiosk, cap] = kioskTx.createKiosk(this.transaction);\n\t\tthis.kiosk = kiosk;\n\t\tthis.kioskCap = cap;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a personal kiosk & shares it.\n\t * The `PersonalKioskCap` is transferred to the signer.\n\t * @param borrow If true, the `kioskOwnerCap` is borrowed from the `PersonalKioskCap` to be used in next transactions.\n\t */\n\tcreatePersonal(borrow?: boolean) {\n\t\tthis.#pendingShare = true;\n\t\treturn this.create().convertToPersonal(borrow);\n\t}\n\n\t/**\n\t * Converts a kiosk to a Personal (Soulbound) Kiosk.\n\t * Requires initialization by either calling `ktxb.create()` or `ktxb.setCap()`.\n\t */\n\tconvertToPersonal(borrow?: boolean) {\n\t\tthis.#validateKioskIsSet();\n\n\t\tconst cap = convertToPersonalTx(\n\t\t\tthis.transaction,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\tthis.kioskClient.getRulePackageId('personalKioskRulePackageId'),\n\t\t);\n\n\t\t// if we enable `borrow`, we borrow the kioskCap from the cap.\n\t\tif (borrow) this.#borrowFromPersonalCap(cap);\n\t\telse this.#personalCap = cap;\n\n\t\tthis.#setPendingStatuses({ transfer: true });\n\t\treturn this;\n\t}\n\n\t/**\n\t * Single function way to create a kiosk, share it and transfer the cap to the specified address.\n\t */\n\tcreateAndShare(address: string) {\n\t\tthis.#validateFinalizedStatus();\n\t\tconst cap = kioskTx.createKioskAndShare(this.transaction);\n\t\tthis.transaction.transferObjects([cap], this.transaction.pure.address(address));\n\t}\n\n\t/**\n\t * Shares the kiosk.\n\t */\n\tshare() {\n\t\tthis.#validateKioskIsSet();\n\t\tthis.#setPendingStatuses({ share: false });\n\t\tkioskTx.shareKiosk(this.transaction, this.kiosk!);\n\t}\n\n\t/**\n\t * Should be called only after `create` is called.\n\t * It shares the kiosk & transfers the cap to the specified address.\n\t */\n\tshareAndTransferCap(address: string) {\n\t\tif (this.#personalCap)\n\t\t\tthrow new Error('You can only call `shareAndTransferCap` on a non-personal kiosk.');\n\t\tthis.#setPendingStatuses({ transfer: false });\n\t\tthis.share();\n\t\tthis.transaction.transferObjects([this.kioskCap!], this.transaction.pure.address(address));\n\t}\n\n\t/**\n\t * A function to borrow an item from a kiosk & execute any function with it.\n\t * Example: You could borrow a Fren out of a kiosk, attach an accessory (or mix), and return it.\n\t */\n\tborrowTx({ itemType, itemId }: ItemId, callback: (item: TransactionArgument) => void) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [itemObj, promise] = kioskTx.borrowValue(\n\t\t\tthis.transaction,\n\t\t\titemType,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\titemId,\n\t\t);\n\n\t\tcallback(itemObj);\n\n\t\tthis.return({ itemType, item: itemObj, promise });\n\t}\n\n\t/**\n\t * Borrows an item from the kiosk.\n\t * This will fail if the item is listed for sale.\n\t *\n\t * Requires calling `return`.\n\t */\n\tborrow({ itemType, itemId }: ItemId): [TransactionArgument, TransactionArgument] {\n\t\tthis.#validateKioskIsSet();\n\t\tconst [itemObj, promise] = kioskTx.borrowValue(\n\t\t\tthis.transaction,\n\t\t\titemType,\n\t\t\tthis.kiosk!,\n\t\t\tthis.kioskCap!,\n\t\t\titemId,\n\t\t);\n\n\t\treturn [itemObj, promise];\n\t}\n\n\t/**\n\t * Returns the item back to the kiosk.\n\t * Accepts the parameters returned from the `borrow` function.\n\t */\n\treturn({ itemType, item, promise }: ItemValue & { promise: TransactionArgument }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.returnValue(this.transaction, itemType, this.kiosk!, item, promise);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to withdraw from kiosk\n\t * @param address Where to trasnfer the coin.\n\t * @param amount The amount we aim to withdraw.\n\t */\n\twithdraw(address: string, amount?: string | bigint | number) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst coin = kioskTx.withdrawFromKiosk(this.transaction, this.kiosk!, this.kioskCap!, amount);\n\t\tthis.transaction.transferObjects([coin], this.transaction.pure.address(address));\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to place an item in the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t */\n\tplace({ itemType, item }: ItemReference) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.place(this.transaction, itemType, this.kiosk!, this.kioskCap!, item);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to place an item in the kiosk and list it for sale in one transaction.\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param price The price in MIST\n\t */\n\tplaceAndList({ itemType, item, price }: ItemReference & Price) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.placeAndList(this.transaction, itemType, this.kiosk!, this.kioskCap!, item, price);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to list an item in the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param price The price in MIST\n\t */\n\tlist({ itemType, itemId, price }: ItemId & { price: string | bigint }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.list(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId, price);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to delist an item from the kiosk.\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n\tdelist({ itemType, itemId }: ItemId) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.delist(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to take an item from the kiosk. The transaction won't succeed if the item is listed or locked.\n\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t */\n\ttake({ itemType, itemId }: ItemId): TransactionObjectArgument {\n\t\tthis.#validateKioskIsSet();\n\t\treturn kioskTx.take(this.transaction, itemType, this.kiosk!, this.kioskCap!, itemId);\n\t}\n\n\t/**\n\t * Transfer a non-locked/non-listed item to an address.\n\t *\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param address The destination address\n\t */\n\ttransfer({ itemType, itemId, address }: ItemId & { address: string }) {\n\t\tthis.#validateKioskIsSet();\n\t\tconst item = this.take({ itemType, itemId });\n\t\tthis.transaction.transferObjects([item], this.transaction.pure.address(address));\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to take lock an item in the kiosk.\n\n\t * @param itemType The type `T` of the item\n\t * @param item The ID or Transaction Argument of the item\n\t * @param itemId The ID of the item - Deprecated: Use `item` instead.\n\t * @param policy The Policy ID or Transaction Argument for item T\n\t */\n\tlock({\n\t\titemType,\n\t\titem,\n\t\titemId,\n\t\tpolicy,\n\t}: ItemReference & { policy: ObjectArgument; itemId?: string }) {\n\t\tthis.#validateKioskIsSet();\n\t\tkioskTx.lock(this.transaction, itemType, this.kiosk!, this.kioskCap!, policy, itemId ?? item);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Purchase an item from a seller's kiosk.\n\t * Returns [item, transferRequest]\n\t * Can be called like: `const [item, transferRequest] = kioskTx.purchase({...})`\n\t * @param itemType The type `T` of the item\n\t * @param itemId The ID of the item\n\t * @param price The price in MIST\n\t * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n\t */\n\tpurchase({\n\t\titemType,\n\t\titemId,\n\t\tprice,\n\t\tsellerKiosk,\n\t}: ItemId & Price & { sellerKiosk: ObjectArgument }): [\n\t\tTransactionObjectArgument,\n\t\tTransactionObjectArgument,\n\t] {\n\t\t// Split the coin for the amount of the listing.\n\t\tconst coin = this.transaction.splitCoins(this.transaction.gas, [\n\t\t\tthis.transaction.pure.u64(price),\n\t\t]);\n\t\treturn kioskTx.purchase(this.transaction, itemType, sellerKiosk, itemId, coin);\n\t}\n\n\t/**\n\t * A function to purchase and resolve a transfer policy.\n\t * If the transfer policy has the `lock` rule, the item is locked in the kiosk.\n\t * Otherwise, the item is placed in the kiosk.\n\t * @param itemType The type of the item\n\t * @param itemId The id of the item\n\t * @param price The price of the specified item\n\t * @param sellerKiosk The kiosk which is selling the item. Can be an id or an object argument.\n\t * @param extraArgs Used to pass arguments for custom rule resolvers.\n\t */\n\tasync purchaseAndResolve({\n\t\titemType,\n\t\titemId,\n\t\tprice,\n\t\tsellerKiosk,\n\t\textraArgs,\n\t}: ItemId & Price & { sellerKiosk: ObjectArgument } & PurchaseOptions) {\n\t\tthis.#validateKioskIsSet();\n\t\t// Get a list of the transfer policies.\n\t\tconst policies = await this.kioskClient.getTransferPolicies({ type: itemType });\n\n\t\tif (policies.length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`The type ${itemType} doesn't have a Transfer Policy so it can't be traded through kiosk.`,\n\t\t\t);\n\t\t}\n\n\t\tconst policy = policies[0]; // we now pick the first one. We need to add an option to define which one.\n\n\t\t// initialize the purchase `kiosk::purchase`\n\t\tconst [purchasedItem, transferRequest] = this.purchase({\n\t\t\titemType,\n\t\t\titemId,\n\t\t\tprice,\n\t\t\tsellerKiosk,\n\t\t});\n\n\t\tlet canTransferOutsideKiosk = true;\n\n\t\tfor (const rule of policy.rules) {\n\t\t\tconst ruleDefinition = this.kioskClient.rules.find(\n\t\t\t\t(x) => getNormalizedRuleType(x.rule) === getNormalizedRuleType(rule),\n\t\t\t);\n\t\t\tif (!ruleDefinition) throw new Error(`No resolver for the following rule: ${rule}.`);\n\n\t\t\tif (ruleDefinition.hasLockingRule) canTransferOutsideKiosk = false;\n\n\t\t\truleDefinition.resolveRuleFunction({\n\t\t\t\tpackageId: ruleDefinition.packageId,\n\t\t\t\ttransactionBlock: this.transaction,\n\t\t\t\ttransaction: this.transaction,\n\t\t\t\titemType,\n\t\t\t\titemId,\n\t\t\t\tprice: price.toString(),\n\t\t\t\tsellerKiosk,\n\t\t\t\tpolicyId: policy.id,\n\t\t\t\ttransferRequest,\n\t\t\t\tpurchasedItem,\n\t\t\t\tkiosk: this.kiosk!,\n\t\t\t\tkioskCap: this.kioskCap!,\n\t\t\t\textraArgs: extraArgs || {},\n\t\t\t});\n\t\t}\n\n\t\tconfirmRequest(this.transaction, itemType, policy.id, transferRequest);\n\n\t\tif (canTransferOutsideKiosk) this.place({ itemType, item: purchasedItem });\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * A function to setup the client using an existing `ownerCap`,\n\t * as return from the `kioskClient.getOwnedKiosks` function.\n\t * @param cap `KioskOwnerCap` object as returned from `getOwnedKiosks` SDK call.\n\t */\n\tsetCap(cap: KioskOwnerCap) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kiosk = this.transaction.object(cap.kioskId);\n\t\tif (!cap.isPersonal) {\n\t\t\tthis.kioskCap = this.transaction.object(cap.objectId);\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.#borrowFromPersonalCap(cap.objectId);\n\t}\n\n\t/**\n\t *\tA function that ends up the kiosk building tx & returns the `kioskOwnerCap` back to the\n\t * `PersonalKioskCap`, in case we are operating on a personal kiosk.\n\t * \tIt will also share the `kiosk` if it's not shared, and finalize the transfer of the personal cap if it's pending.\n\t */\n\tfinalize() {\n\t\tthis.#validateKioskIsSet();\n\t\t// If we're pending the sharing of the new kiosk, share it.\n\t\tif (this.#pendingShare) this.share();\n\n\t\t// If we're operating on a non-personal kiosk, we don't need to do anything else.\n\t\tif (!this.#personalCap) {\n\t\t\t// If we're pending transfer though, we inform user to call `shareAndTransferCap()`.\n\t\t\tif (this.#pendingTransfer)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'You need to transfer the `kioskOwnerCap` by calling `shareAndTransferCap()` before wrap',\n\t\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst packageId = this.kioskClient.getRulePackageId('personalKioskRulePackageId');\n\n\t\t// if we have a promise, return the `ownerCap` back to the personal cap.\n\t\tif (this.#promise) {\n\t\t\tthis.transaction.moveCall({\n\t\t\t\ttarget: `${packageId}::personal_kiosk::return_val`,\n\t\t\t\targuments: [this.#personalCap, this.transaction.object(this.kioskCap!), this.#promise!],\n\t\t\t});\n\t\t}\n\n\t\t// If we are pending transferring the personalCap, we do it here.\n\t\tif (this.#pendingTransfer)\n\t\t\ttransferPersonalCapTx(this.transaction, this.#personalCap, packageId);\n\n\t\t// Mark the transaction as finalized, so no other functions can be called.\n\t\tthis.#finalized = true;\n\t}\n\n\t// Some setters in case we want custom behavior.\n\tsetKioskCap(cap: TransactionObjectArgument) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kioskCap = cap;\n\t\treturn this;\n\t}\n\n\tsetKiosk(kiosk: TransactionObjectArgument) {\n\t\tthis.#validateFinalizedStatus();\n\t\tthis.kiosk = kiosk;\n\t\treturn this;\n\t}\n\n\t// Some getters\n\t/*\n\t * Returns the active transaction's kiosk, or undefined if `setCap` or `create()` hasn't been called yet.\n\t */\n\tgetKiosk() {\n\t\tthis.#validateFinalizedStatus();\n\t\tif (!this.kiosk) throw new Error('Kiosk is not set.');\n\t\treturn this.kiosk;\n\t}\n\n\t/*\n\t * Returns the active transaction's kioskOwnerCap, or undefined if `setCap` or `create()` hasn't been called yet.\n\t */\n\tgetKioskCap() {\n\t\tthis.#validateFinalizedStatus();\n\t\tif (!this.kioskCap) throw new Error('Kiosk cap is not set');\n\t\treturn this.kioskCap;\n\t}\n\n\t/**\n\t * A function to borrow from `personalCap`.\n\t */\n\t#borrowFromPersonalCap(personalCap: ObjectArgument) {\n\t\tconst [kioskCap, promise] = this.transaction.moveCall({\n\t\t\ttarget: `${this.kioskClient.getRulePackageId(\n\t\t\t\t'personalKioskRulePackageId',\n\t\t\t)}::personal_kiosk::borrow_val`,\n\t\t\targuments: [this.transaction.object(personalCap)],\n\t\t});\n\n\t\tthis.kioskCap = kioskCap;\n\t\tthis.#personalCap = this.transaction.object(personalCap);\n\t\tthis.#promise = promise;\n\n\t\treturn this;\n\t}\n\n\t#setPendingStatuses({ share, transfer }: { share?: boolean; transfer?: boolean }) {\n\t\tif (transfer !== undefined) this.#pendingTransfer = transfer;\n\t\tif (share !== undefined) this.#pendingShare = share;\n\t}\n\n\t#validateKioskIsSet() {\n\t\tthis.#validateFinalizedStatus();\n\n\t\tif (!this.kiosk || !this.kioskCap)\n\t\t\tthrow new Error(\n\t\t\t\t'You need to initialize the client by either supplying an existing owner cap or by creating a new by calling `.create()`',\n\t\t\t);\n\t}\n\n\t// Validates that `finalize`\n\t#validateFinalizedStatus() {\n\t\tif (this.#finalized)\n\t\t\tthrow new Error(\"You can't add more transactions to a finalized kiosk transaction.\");\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,cAAyB;AACzB,4BAA2D;AAC3D,6BAA+B;AAU/B,mBAAsC;AArBtC;AA6CO,MAAM,iBAAiB;AAAA,EAgB7B,YAAY;AAAA,IACX;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACD,GAA2B;AAqa3B;AAAA;AAAA;AAAA;AAeA;AAKA;AAUA;AAAA;AAldA;AAAA;AAEA;AAAA;AAEA;AAAA;AAEA;AAAA;AAEA;AAAA,mCAAsB;AAQrB,SAAK,cAAc;AACnB,SAAK,cAAc;AAEnB,QAAI;AAAK,WAAK,OAAO,GAAG;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS;AACR,0BAAK,sDAAL;AACA,0BAAK,4CAAL,WAAyB;AAAA,MACxB,OAAO;AAAA,MACP,UAAU;AAAA,IACX;AACA,UAAM,CAAC,OAAO,GAAG,IAAI,QAAQ,YAAY,KAAK,WAAW;AACzD,SAAK,QAAQ;AACb,SAAK,WAAW;AAChB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,eAAe,QAAkB;AAChC,uBAAK,eAAgB;AACrB,WAAO,KAAK,OAAO,EAAE,kBAAkB,MAAM;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,kBAAkB,QAAkB;AACnC,0BAAK,4CAAL;AAEA,UAAM,UAAM;AAAA,MACX,KAAK;AAAA,MACL,KAA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