@iota/kiosk 0.1.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 +12 -0
- package/LICENSE +201 -0
- package/README.md +8 -0
- package/dist/cjs/bcs.d.ts +2 -0
- package/dist/cjs/bcs.js +47 -0
- package/dist/cjs/bcs.js.map +7 -0
- package/dist/cjs/client/kiosk-client.d.ts +74 -0
- package/dist/cjs/client/kiosk-client.js +121 -0
- package/dist/cjs/client/kiosk-client.js.map +7 -0
- package/dist/cjs/client/kiosk-transaction.d.ts +184 -0
- package/dist/cjs/client/kiosk-transaction.js +511 -0
- package/dist/cjs/client/kiosk-transaction.js.map +7 -0
- package/dist/cjs/client/tp-transaction.d.ts +112 -0
- package/dist/cjs/client/tp-transaction.js +323 -0
- package/dist/cjs/client/tp-transaction.js.map +7 -0
- package/dist/cjs/constants.d.ts +24 -0
- package/dist/cjs/constants.js +66 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +24 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/query/kiosk.d.ts +14 -0
- package/dist/cjs/query/kiosk.js +128 -0
- package/dist/cjs/query/kiosk.js.map +7 -0
- package/dist/cjs/query/transfer-policy.d.ts +28 -0
- package/dist/cjs/query/transfer-policy.js +96 -0
- package/dist/cjs/query/transfer-policy.js.map +7 -0
- package/dist/cjs/tx/kiosk.d.ts +71 -0
- package/dist/cjs/tx/kiosk.js +130 -0
- package/dist/cjs/tx/kiosk.js.map +7 -0
- package/dist/cjs/tx/personal-kiosk.d.ts +7 -0
- package/dist/cjs/tx/personal-kiosk.js +38 -0
- package/dist/cjs/tx/personal-kiosk.js.map +7 -0
- package/dist/cjs/tx/rules/attach.d.ts +7 -0
- package/dist/cjs/tx/rules/attach.js +62 -0
- package/dist/cjs/tx/rules/attach.js.map +7 -0
- package/dist/cjs/tx/rules/resolve.d.ts +15 -0
- package/dist/cjs/tx/rules/resolve.js +81 -0
- package/dist/cjs/tx/rules/resolve.js.map +7 -0
- package/dist/cjs/tx/transfer-policy.d.ts +29 -0
- package/dist/cjs/tx/transfer-policy.js +78 -0
- package/dist/cjs/tx/transfer-policy.js.map +7 -0
- package/dist/cjs/types/index.d.ts +17 -0
- package/dist/cjs/types/index.js +20 -0
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/types/kiosk.d.ts +160 -0
- package/dist/cjs/types/kiosk.js +37 -0
- package/dist/cjs/types/kiosk.js.map +7 -0
- package/dist/cjs/types/transfer-policy.d.ts +49 -0
- package/dist/cjs/types/transfer-policy.js +35 -0
- package/dist/cjs/types/transfer-policy.js.map +7 -0
- package/dist/cjs/utils.d.ts +51 -0
- package/dist/cjs/utils.js +204 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/bcs.d.ts +2 -0
- package/dist/esm/bcs.js +32 -0
- package/dist/esm/bcs.js.map +7 -0
- package/dist/esm/client/kiosk-client.d.ts +74 -0
- package/dist/esm/client/kiosk-client.js +105 -0
- package/dist/esm/client/kiosk-client.js.map +7 -0
- package/dist/esm/client/kiosk-transaction.d.ts +184 -0
- package/dist/esm/client/kiosk-transaction.js +481 -0
- package/dist/esm/client/kiosk-transaction.js.map +7 -0
- package/dist/esm/client/tp-transaction.d.ts +112 -0
- package/dist/esm/client/tp-transaction.js +314 -0
- package/dist/esm/client/tp-transaction.js.map +7 -0
- package/dist/esm/constants.d.ts +24 -0
- package/dist/esm/constants.js +51 -0
- package/dist/esm/constants.js.map +7 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/query/kiosk.d.ts +14 -0
- package/dist/esm/query/kiosk.js +116 -0
- package/dist/esm/query/kiosk.js.map +7 -0
- package/dist/esm/query/transfer-policy.d.ts +28 -0
- package/dist/esm/query/transfer-policy.js +80 -0
- package/dist/esm/query/transfer-policy.js.map +7 -0
- package/dist/esm/tx/kiosk.d.ts +71 -0
- package/dist/esm/tx/kiosk.js +110 -0
- package/dist/esm/tx/kiosk.js.map +7 -0
- package/dist/esm/tx/personal-kiosk.d.ts +7 -0
- package/dist/esm/tx/personal-kiosk.js +18 -0
- package/dist/esm/tx/personal-kiosk.js.map +7 -0
- package/dist/esm/tx/rules/attach.d.ts +7 -0
- package/dist/esm/tx/rules/attach.js +42 -0
- package/dist/esm/tx/rules/attach.js.map +7 -0
- package/dist/esm/tx/rules/resolve.d.ts +15 -0
- package/dist/esm/tx/rules/resolve.js +61 -0
- package/dist/esm/tx/rules/resolve.js.map +7 -0
- package/dist/esm/tx/transfer-policy.d.ts +29 -0
- package/dist/esm/tx/transfer-policy.js +58 -0
- package/dist/esm/tx/transfer-policy.js.map +7 -0
- package/dist/esm/types/index.d.ts +17 -0
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/types/index.js.map +7 -0
- package/dist/esm/types/kiosk.d.ts +160 -0
- package/dist/esm/types/kiosk.js +17 -0
- package/dist/esm/types/kiosk.js.map +7 -0
- package/dist/esm/types/transfer-policy.d.ts +49 -0
- package/dist/esm/types/transfer-policy.js +15 -0
- package/dist/esm/types/transfer-policy.js.map +7 -0
- package/dist/esm/utils.d.ts +51 -0
- package/dist/esm/utils.js +184 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +52 -0
- package/src/bcs.ts +42 -0
- package/src/client/kiosk-client.ts +159 -0
- package/src/client/kiosk-transaction.ts +542 -0
- package/src/client/tp-transaction.ts +360 -0
- package/src/constants.ts +85 -0
- package/src/index.ts +10 -0
- package/src/query/kiosk.ts +190 -0
- package/src/query/transfer-policy.ts +135 -0
- package/src/tx/kiosk.ts +244 -0
- package/src/tx/personal-kiosk.ts +35 -0
- package/src/tx/rules/attach.ts +74 -0
- package/src/tx/rules/resolve.ts +87 -0
- package/src/tx/transfer-policy.ts +121 -0
- package/src/types/index.ts +25 -0
- package/src/types/kiosk.ts +179 -0
- package/src/types/transfer-policy.ts +68 -0
- package/src/utils.ts +284 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./utils.js"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./types/index.js"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./constants.js"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./client/kiosk-client.js"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./client/tp-transaction.js"), module.exports);
|
|
23
|
+
__reExport(src_exports, require("./client/kiosk-transaction.js"), module.exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from './utils.js';\nexport * from './types/index.js';\nexport * from './constants.js';\nexport * from './client/kiosk-client.js';\nexport * from './client/tp-transaction.js';\nexport * from './client/kiosk-transaction.js';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAIA,wBAAc,uBAJd;AAKA,wBAAc,6BALd;AAMA,wBAAc,2BANd;AAOA,wBAAc,qCAPd;AAQA,wBAAc,uCARd;AASA,wBAAc,0CATd;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PaginationArguments, IotaClient } from '@iota/iota-sdk/client';
|
|
2
|
+
import type { FetchKioskOptions, KioskExtension, OwnedKiosks, PagedKioskData } from '../types/index.js';
|
|
3
|
+
export declare function fetchKiosk(client: IotaClient, kioskId: string, pagination: PaginationArguments<string>, options: FetchKioskOptions): Promise<PagedKioskData>;
|
|
4
|
+
/**
|
|
5
|
+
* A function to fetch all the user's kiosk Caps
|
|
6
|
+
* And a list of the kiosk address ids.
|
|
7
|
+
* Returns a list of `kioskOwnerCapIds` and `kioskIds`.
|
|
8
|
+
* Extra options allow pagination.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getOwnedKiosks(client: IotaClient, address: string, options?: {
|
|
11
|
+
pagination?: PaginationArguments<string>;
|
|
12
|
+
personalKioskType: string;
|
|
13
|
+
}): Promise<OwnedKiosks>;
|
|
14
|
+
export declare function fetchKioskExtension(client: IotaClient, kioskId: string, extensionType: string): Promise<KioskExtension | null>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var kiosk_exports = {};
|
|
20
|
+
__export(kiosk_exports, {
|
|
21
|
+
fetchKiosk: () => fetchKiosk,
|
|
22
|
+
fetchKioskExtension: () => fetchKioskExtension,
|
|
23
|
+
getOwnedKiosks: () => getOwnedKiosks
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(kiosk_exports);
|
|
26
|
+
var import_utils = require("@iota/iota-sdk/utils");
|
|
27
|
+
var import_types = require("../types/index.js");
|
|
28
|
+
var import_utils2 = require("../utils.js");
|
|
29
|
+
async function fetchKiosk(client, kioskId, pagination, options) {
|
|
30
|
+
const data = await (0, import_utils2.getAllDynamicFields)(client, kioskId, pagination);
|
|
31
|
+
const listings = [];
|
|
32
|
+
const lockedItemIds = [];
|
|
33
|
+
const kioskData = (0, import_utils2.extractKioskData)(data, listings, lockedItemIds, kioskId);
|
|
34
|
+
const [kiosk, listingObjects, items] = await Promise.all([
|
|
35
|
+
options.withKioskFields ? (0, import_utils2.getKioskObject)(client, kioskId) : Promise.resolve(void 0),
|
|
36
|
+
options.withListingPrices ? (0, import_utils2.getAllObjects)(client, kioskData.listingIds, {
|
|
37
|
+
showContent: true
|
|
38
|
+
}) : Promise.resolve([]),
|
|
39
|
+
options.withObjects ? (0, import_utils2.getAllObjects)(
|
|
40
|
+
client,
|
|
41
|
+
kioskData.itemIds,
|
|
42
|
+
options.objectOptions || { showDisplay: true }
|
|
43
|
+
) : Promise.resolve([])
|
|
44
|
+
]);
|
|
45
|
+
if (options.withKioskFields)
|
|
46
|
+
kioskData.kiosk = kiosk;
|
|
47
|
+
(0, import_utils2.attachListingsAndPrices)(kioskData, listings, listingObjects);
|
|
48
|
+
(0, import_utils2.attachLockedItems)(kioskData, lockedItemIds);
|
|
49
|
+
(0, import_utils2.attachObjects)(
|
|
50
|
+
kioskData,
|
|
51
|
+
items.filter((x) => !!x.data).map((x) => x.data)
|
|
52
|
+
);
|
|
53
|
+
return {
|
|
54
|
+
data: kioskData,
|
|
55
|
+
nextCursor: null,
|
|
56
|
+
hasNextPage: false
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function getOwnedKiosks(client, address, options) {
|
|
60
|
+
if (!(0, import_utils.isValidIotaAddress)(address))
|
|
61
|
+
return {
|
|
62
|
+
nextCursor: null,
|
|
63
|
+
hasNextPage: false,
|
|
64
|
+
kioskOwnerCaps: [],
|
|
65
|
+
kioskIds: []
|
|
66
|
+
};
|
|
67
|
+
const filter = {
|
|
68
|
+
MatchAny: [
|
|
69
|
+
{
|
|
70
|
+
StructType: import_types.KIOSK_OWNER_CAP
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
};
|
|
74
|
+
if (options?.personalKioskType) {
|
|
75
|
+
filter.MatchAny.push({
|
|
76
|
+
StructType: options.personalKioskType
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const { data, hasNextPage, nextCursor } = await client.getOwnedObjects({
|
|
80
|
+
owner: address,
|
|
81
|
+
filter,
|
|
82
|
+
options: {
|
|
83
|
+
showContent: true,
|
|
84
|
+
showType: true
|
|
85
|
+
},
|
|
86
|
+
...options?.pagination || {}
|
|
87
|
+
});
|
|
88
|
+
const kioskIdList = data?.map((x) => {
|
|
89
|
+
const fields = x.data?.content?.dataType === "moveObject" ? x.data.content.fields : null;
|
|
90
|
+
return fields?.cap ? fields?.cap?.fields?.for : fields?.for;
|
|
91
|
+
});
|
|
92
|
+
const filteredData = data.filter((x) => "data" in x).map((x) => x.data);
|
|
93
|
+
return {
|
|
94
|
+
nextCursor,
|
|
95
|
+
hasNextPage,
|
|
96
|
+
kioskOwnerCaps: filteredData.map((x, idx) => ({
|
|
97
|
+
isPersonal: x.type !== import_types.KIOSK_OWNER_CAP,
|
|
98
|
+
digest: x.digest,
|
|
99
|
+
version: x.version,
|
|
100
|
+
objectId: x.objectId,
|
|
101
|
+
kioskId: kioskIdList[idx]
|
|
102
|
+
})),
|
|
103
|
+
kioskIds: kioskIdList
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async function fetchKioskExtension(client, kioskId, extensionType) {
|
|
107
|
+
const extension = await client.getDynamicFieldObject({
|
|
108
|
+
parentId: kioskId,
|
|
109
|
+
name: {
|
|
110
|
+
type: `0x2::kiosk_extension::ExtensionKey<${extensionType}>`,
|
|
111
|
+
value: {
|
|
112
|
+
dummy_field: false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
if (!extension.data)
|
|
117
|
+
return null;
|
|
118
|
+
const fields = extension?.data?.content?.fields?.value?.fields;
|
|
119
|
+
return {
|
|
120
|
+
objectId: extension.data.objectId,
|
|
121
|
+
type: extensionType,
|
|
122
|
+
isEnabled: fields?.is_enabled,
|
|
123
|
+
permissions: fields?.permissions,
|
|
124
|
+
storageId: fields?.storage?.fields?.id?.id,
|
|
125
|
+
storageSize: fields?.storage?.fields?.size
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=kiosk.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/query/kiosk.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n PaginationArguments,\n IotaClient,\n IotaObjectData,\n IotaObjectDataFilter,\n IotaObjectResponse,\n} from '@iota/iota-sdk/client';\nimport { isValidIotaAddress } from '@iota/iota-sdk/utils';\n\nimport type {\n FetchKioskOptions,\n KioskExtension,\n KioskListing,\n OwnedKiosks,\n PagedKioskData,\n} from '../types/index.js';\nimport { KIOSK_OWNER_CAP } from '../types/index.js';\nimport {\n attachListingsAndPrices,\n attachLockedItems,\n attachObjects,\n extractKioskData,\n getAllDynamicFields,\n getAllObjects,\n getKioskObject,\n} from '../utils.js';\n\nexport async function fetchKiosk(\n client: IotaClient,\n kioskId: string,\n pagination: PaginationArguments<string>,\n options: FetchKioskOptions,\n): Promise<PagedKioskData> {\n // TODO: Replace the `getAllDynamicFields` with a paginated\n // response, once we have better RPC support for\n // type filtering & batch fetching.\n // This can't work with pagination currently.\n const data = await getAllDynamicFields(client, kioskId, pagination);\n\n const listings: KioskListing[] = [];\n const lockedItemIds: string[] = [];\n\n // extracted kiosk data.\n const kioskData = extractKioskData(data, listings, lockedItemIds, kioskId);\n\n // split the fetching in two queries as we are most likely passing different options for each kind.\n // For items, we usually seek the Display.\n // For listings we usually seek the DF value (price) / exclusivity.\n const [kiosk, listingObjects, items] = await Promise.all([\n options.withKioskFields ? getKioskObject(client, kioskId) : Promise.resolve(undefined),\n options.withListingPrices\n ? getAllObjects(client, kioskData.listingIds, {\n showContent: true,\n })\n : Promise.resolve([]),\n options.withObjects\n ? getAllObjects(\n client,\n kioskData.itemIds,\n options.objectOptions || { showDisplay: true },\n )\n : Promise.resolve([]),\n ]);\n\n if (options.withKioskFields) kioskData.kiosk = kiosk;\n // attach items listings. IF we have `options.withListingPrices === true`, it will also attach the prices.\n attachListingsAndPrices(kioskData, listings, listingObjects);\n // add `locked` status to items that are locked.\n attachLockedItems(kioskData, lockedItemIds);\n\n // Attach the objects for the queried items.\n attachObjects(\n kioskData,\n items.filter((x) => !!x.data).map((x) => x.data!),\n );\n\n return {\n data: kioskData,\n nextCursor: null,\n hasNextPage: false,\n };\n}\n\n/**\n * A function to fetch all the user's kiosk Caps\n * And a list of the kiosk address ids.\n * Returns a list of `kioskOwnerCapIds` and `kioskIds`.\n * Extra options allow pagination.\n */\nexport async function getOwnedKiosks(\n client: IotaClient,\n address: string,\n options?: {\n pagination?: PaginationArguments<string>;\n personalKioskType: string;\n },\n): Promise<OwnedKiosks> {\n if (!isValidIotaAddress(address))\n return {\n nextCursor: null,\n hasNextPage: false,\n kioskOwnerCaps: [],\n kioskIds: [],\n };\n\n const filter: IotaObjectDataFilter = {\n MatchAny: [\n {\n StructType: KIOSK_OWNER_CAP,\n },\n ],\n };\n\n if (options?.personalKioskType) {\n filter.MatchAny.push({\n StructType: options.personalKioskType,\n });\n }\n\n // fetch owned kiosk caps, paginated.\n const { data, hasNextPage, nextCursor } = await client.getOwnedObjects({\n owner: address,\n filter,\n options: {\n showContent: true,\n showType: true,\n },\n ...(options?.pagination || {}),\n });\n\n // get kioskIds from the OwnerCaps.\n const kioskIdList = data?.map((x: IotaObjectResponse) => {\n const fields = x.data?.content?.dataType === 'moveObject' ? x.data.content.fields : null;\n // @ts-expect-error TODO: should i remove ts ignore here?\n return (fields?.cap ? fields?.cap?.fields?.for : fields?.for) as string;\n // return (fields as { for: string })?.for;\n });\n\n // clean up data that might have an error in them.\n // only return valid objects.\n const filteredData = data.filter((x) => 'data' in x).map((x) => x.data) as IotaObjectData[];\n\n return {\n nextCursor,\n hasNextPage,\n kioskOwnerCaps: filteredData.map((x, idx) => ({\n isPersonal: x.type !== KIOSK_OWNER_CAP,\n digest: x.digest,\n version: x.version,\n objectId: x.objectId,\n kioskId: kioskIdList[idx],\n })),\n kioskIds: kioskIdList,\n };\n}\n\n// Get a kiosk extension data for a given kioskId and extensionType.\nexport async function fetchKioskExtension(\n client: IotaClient,\n kioskId: string,\n extensionType: string,\n): Promise<KioskExtension | null> {\n const extension = await client.getDynamicFieldObject({\n parentId: kioskId,\n name: {\n type: `0x2::kiosk_extension::ExtensionKey<${extensionType}>`,\n value: {\n dummy_field: false,\n },\n },\n });\n\n if (!extension.data) return null;\n\n const fields = (extension?.data?.content as { fields: { [k: string]: any } })?.fields?.value\n ?.fields;\n\n return {\n objectId: extension.data.objectId,\n type: extensionType,\n isEnabled: fields?.is_enabled,\n permissions: fields?.permissions,\n storageId: fields?.storage?.fields?.id?.id,\n storageSize: fields?.storage?.fields?.size,\n };\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_utils"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IotaClient } from '@iota/iota-sdk/client';
|
|
2
|
+
import type { TransferPolicy, TransferPolicyCap } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Searches the `TransferPolicy`-s for the given type. The search is performed via
|
|
5
|
+
* the `TransferPolicyCreated` event. The policy can either be owned or shared,
|
|
6
|
+
* and the caller needs to filter the results accordingly (ie single owner can not
|
|
7
|
+
* be accessed by anyone but the owner).
|
|
8
|
+
*
|
|
9
|
+
* @param provider
|
|
10
|
+
* @param type
|
|
11
|
+
*/
|
|
12
|
+
export declare function queryTransferPolicy(client: IotaClient, type: string): Promise<TransferPolicy[]>;
|
|
13
|
+
/**
|
|
14
|
+
* A function to fetch all the user's kiosk Caps
|
|
15
|
+
* And a list of the kiosk address ids.
|
|
16
|
+
* Returns a list of `kioskOwnerCapIds` and `kioskIds`.
|
|
17
|
+
* Extra options allow pagination.
|
|
18
|
+
* @returns TransferPolicyCap Object ID | undefined if not found.
|
|
19
|
+
*/
|
|
20
|
+
export declare function queryTransferPolicyCapsByType(client: IotaClient, address: string, type: string): Promise<TransferPolicyCap[]>;
|
|
21
|
+
/**
|
|
22
|
+
* A function to fetch all the user's kiosk Caps
|
|
23
|
+
* And a list of the kiosk address ids.
|
|
24
|
+
* Returns a list of `kioskOwnerCapIds` and `kioskIds`.
|
|
25
|
+
* Extra options allow pagination.
|
|
26
|
+
* @returns TransferPolicyCap Object ID | undefined if not found.
|
|
27
|
+
*/
|
|
28
|
+
export declare function queryOwnedTransferPolicies(client: IotaClient, address: string): Promise<TransferPolicyCap[] | undefined>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var transfer_policy_exports = {};
|
|
20
|
+
__export(transfer_policy_exports, {
|
|
21
|
+
queryOwnedTransferPolicies: () => queryOwnedTransferPolicies,
|
|
22
|
+
queryTransferPolicy: () => queryTransferPolicy,
|
|
23
|
+
queryTransferPolicyCapsByType: () => queryTransferPolicyCapsByType
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(transfer_policy_exports);
|
|
26
|
+
var import_utils = require("@iota/iota-sdk/utils");
|
|
27
|
+
var import_bcs = require("../bcs.js");
|
|
28
|
+
var import_types = require("../types/index.js");
|
|
29
|
+
var import_utils2 = require("../utils.js");
|
|
30
|
+
async function queryTransferPolicy(client, type) {
|
|
31
|
+
const { data } = await client.queryEvents({
|
|
32
|
+
query: {
|
|
33
|
+
MoveEventType: `${import_types.TRANSFER_POLICY_CREATED_EVENT}<${type}>`
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const search = data.map((event) => event.parsedJson);
|
|
37
|
+
const policies = await client.multiGetObjects({
|
|
38
|
+
ids: search.map((policy) => policy.id),
|
|
39
|
+
options: { showBcs: true, showOwner: true }
|
|
40
|
+
});
|
|
41
|
+
return policies.filter((policy) => !!policy && "data" in policy).map(({ data: policy }) => {
|
|
42
|
+
if (!policy || !policy.bcs || !("bcsBytes" in policy.bcs)) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Invalid policy: ${policy?.objectId}, expected object, got package`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const parsed = import_bcs.bcs.de(import_types.TRANSFER_POLICY_TYPE, policy.bcs.bcsBytes, "base64");
|
|
48
|
+
return {
|
|
49
|
+
id: policy?.objectId,
|
|
50
|
+
type: `${import_types.TRANSFER_POLICY_TYPE}<${type}>`,
|
|
51
|
+
owner: policy?.owner,
|
|
52
|
+
rules: parsed.rules,
|
|
53
|
+
balance: parsed.balance
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function queryTransferPolicyCapsByType(client, address, type) {
|
|
58
|
+
if (!(0, import_utils.isValidIotaAddress)(address))
|
|
59
|
+
return [];
|
|
60
|
+
const filter = {
|
|
61
|
+
MatchAll: [
|
|
62
|
+
{
|
|
63
|
+
StructType: `${import_types.TRANSFER_POLICY_CAP_TYPE}<${type}>`
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
const data = await (0, import_utils2.getAllOwnedObjects)({
|
|
68
|
+
client,
|
|
69
|
+
filter,
|
|
70
|
+
owner: address
|
|
71
|
+
});
|
|
72
|
+
return data.map((item) => (0, import_utils2.parseTransferPolicyCapObject)(item)).filter((item) => !!item);
|
|
73
|
+
}
|
|
74
|
+
async function queryOwnedTransferPolicies(client, address) {
|
|
75
|
+
if (!(0, import_utils.isValidIotaAddress)(address))
|
|
76
|
+
return;
|
|
77
|
+
const filter = {
|
|
78
|
+
MatchAll: [
|
|
79
|
+
{
|
|
80
|
+
MoveModule: {
|
|
81
|
+
module: "transfer_policy",
|
|
82
|
+
package: "0x2"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
const data = await (0, import_utils2.getAllOwnedObjects)({ client, owner: address, filter });
|
|
88
|
+
const policies = [];
|
|
89
|
+
for (const item of data) {
|
|
90
|
+
const data2 = (0, import_utils2.parseTransferPolicyCapObject)(item);
|
|
91
|
+
if (data2)
|
|
92
|
+
policies.push(data2);
|
|
93
|
+
}
|
|
94
|
+
return policies;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=transfer-policy.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/query/transfer-policy.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { IotaClient } from '@iota/iota-sdk/client';\nimport { isValidIotaAddress } from '@iota/iota-sdk/utils';\n\nimport { bcs } from '../bcs.js';\nimport type { TransferPolicy, TransferPolicyCap } from '../types/index.js';\nimport {\n TRANSFER_POLICY_CAP_TYPE,\n TRANSFER_POLICY_CREATED_EVENT,\n TRANSFER_POLICY_TYPE,\n} from '../types/index.js';\nimport { getAllOwnedObjects, parseTransferPolicyCapObject } from '../utils.js';\n\n/**\n * Searches the `TransferPolicy`-s for the given type. The search is performed via\n * the `TransferPolicyCreated` event. The policy can either be owned or shared,\n * and the caller needs to filter the results accordingly (ie single owner can not\n * be accessed by anyone but the owner).\n *\n * @param provider\n * @param type\n */\nexport async function queryTransferPolicy(\n client: IotaClient,\n type: string,\n): Promise<TransferPolicy[]> {\n // console.log('event type: %s', `${TRANSFER_POLICY_CREATED_EVENT}<${type}>`);\n const { data } = await client.queryEvents({\n query: {\n MoveEventType: `${TRANSFER_POLICY_CREATED_EVENT}<${type}>`,\n },\n });\n\n const search = data.map((event) => event.parsedJson as { id: string });\n const policies = await client.multiGetObjects({\n ids: search.map((policy) => policy.id),\n options: { showBcs: true, showOwner: true },\n });\n\n return policies\n .filter((policy) => !!policy && 'data' in policy)\n .map(({ data: policy }) => {\n // should never happen; policies are objects and fetched via an event.\n // policies are filtered for null and undefined above.\n if (!policy || !policy.bcs || !('bcsBytes' in policy.bcs)) {\n throw new Error(\n `Invalid policy: ${policy?.objectId}, expected object, got package`,\n );\n }\n\n const parsed = bcs.de(TRANSFER_POLICY_TYPE, policy.bcs.bcsBytes, 'base64');\n\n return {\n id: policy?.objectId,\n type: `${TRANSFER_POLICY_TYPE}<${type}>`,\n owner: policy?.owner,\n rules: parsed.rules,\n balance: parsed.balance,\n } as TransferPolicy;\n });\n}\n\n/**\n * A function to fetch all the user's kiosk Caps\n * And a list of the kiosk address ids.\n * Returns a list of `kioskOwnerCapIds` and `kioskIds`.\n * Extra options allow pagination.\n * @returns TransferPolicyCap Object ID | undefined if not found.\n */\nexport async function queryTransferPolicyCapsByType(\n client: IotaClient,\n address: string,\n type: string,\n): Promise<TransferPolicyCap[]> {\n if (!isValidIotaAddress(address)) return [];\n\n const filter = {\n MatchAll: [\n {\n StructType: `${TRANSFER_POLICY_CAP_TYPE}<${type}>`,\n },\n ],\n };\n\n // fetch owned kiosk caps, paginated.\n const data = await getAllOwnedObjects({\n client,\n filter,\n owner: address,\n });\n\n return data\n .map((item) => parseTransferPolicyCapObject(item))\n .filter((item) => !!item) as TransferPolicyCap[];\n}\n\n/**\n * A function to fetch all the user's kiosk Caps\n * And a list of the kiosk address ids.\n * Returns a list of `kioskOwnerCapIds` and `kioskIds`.\n * Extra options allow pagination.\n * @returns TransferPolicyCap Object ID | undefined if not found.\n */\nexport async function queryOwnedTransferPolicies(\n client: IotaClient,\n address: string,\n): Promise<TransferPolicyCap[] | undefined> {\n if (!isValidIotaAddress(address)) return;\n\n const filter = {\n MatchAll: [\n {\n MoveModule: {\n module: 'transfer_policy',\n package: '0x2',\n },\n },\n ],\n };\n\n // fetch all owned kiosk caps, paginated.\n const data = await getAllOwnedObjects({ client, owner: address, filter });\n\n const policies: TransferPolicyCap[] = [];\n\n for (const item of data) {\n const data = parseTransferPolicyCapObject(item);\n if (data) policies.push(data);\n }\n\n return policies;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,mBAAmC;AAEnC,iBAAoB;AAEpB,mBAIO;AACP,IAAAA,gBAAiE;AAWjE,eAAsB,oBAClB,QACA,MACyB;AAEzB,QAAM,EAAE,KAAK,IAAI,MAAM,OAAO,YAAY;AAAA,IACtC,OAAO;AAAA,MACH,eAAe,GAAG,8CAAiC;AAAA,IACvD;AAAA,EACJ,CAAC;AAED,QAAM,SAAS,KAAK,IAAI,CAAC,UAAU,MAAM,UAA4B;AACrE,QAAM,WAAW,MAAM,OAAO,gBAAgB;AAAA,IAC1C,KAAK,OAAO,IAAI,CAAC,WAAW,OAAO,EAAE;AAAA,IACrC,SAAS,EAAE,SAAS,MAAM,WAAW,KAAK;AAAA,EAC9C,CAAC;AAED,SAAO,SACF,OAAO,CAAC,WAAW,CAAC,CAAC,UAAU,UAAU,MAAM,EAC/C,IAAI,CAAC,EAAE,MAAM,OAAO,MAAM;AAGvB,QAAI,CAAC,UAAU,CAAC,OAAO,OAAO,EAAE,cAAc,OAAO,MAAM;AACvD,YAAM,IAAI;AAAA,QACN,mBAAmB,QAAQ;AAAA,MAC/B;AAAA,IACJ;AAEA,UAAM,SAAS,eAAI,GAAG,mCAAsB,OAAO,IAAI,UAAU,QAAQ;AAEzE,WAAO;AAAA,MACH,IAAI,QAAQ;AAAA,MACZ,MAAM,GAAG,qCAAwB;AAAA,MACjC,OAAO,QAAQ;AAAA,MACf,OAAO,OAAO;AAAA,MACd,SAAS,OAAO;AAAA,IACpB;AAAA,EACJ,CAAC;AACT;AASA,eAAsB,8BAClB,QACA,SACA,MAC4B;AAC5B,MAAI,KAAC,iCAAmB,OAAO;AAAG,WAAO,CAAC;AAE1C,QAAM,SAAS;AAAA,IACX,UAAU;AAAA,MACN;AAAA,QACI,YAAY,GAAG,yCAA4B;AAAA,MAC/C;AAAA,IACJ;AAAA,EACJ;AAGA,QAAM,OAAO,UAAM,kCAAmB;AAAA,IAClC;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACX,CAAC;AAED,SAAO,KACF,IAAI,CAAC,aAAS,4CAA6B,IAAI,CAAC,EAChD,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI;AAChC;AASA,eAAsB,2BAClB,QACA,SACwC;AACxC,MAAI,KAAC,iCAAmB,OAAO;AAAG;AAElC,QAAM,SAAS;AAAA,IACX,UAAU;AAAA,MACN;AAAA,QACI,YAAY;AAAA,UACR,QAAQ;AAAA,UACR,SAAS;AAAA,QACb;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AAGA,QAAM,OAAO,UAAM,kCAAmB,EAAE,QAAQ,OAAO,SAAS,OAAO,CAAC;AAExE,QAAM,WAAgC,CAAC;AAEvC,aAAW,QAAQ,MAAM;AACrB,UAAMC,YAAO,4CAA6B,IAAI;AAC9C,QAAIA;AAAM,eAAS,KAAKA,KAAI;AAAA,EAChC;AAEA,SAAO;AACX;",
|
|
6
|
+
"names": ["import_utils", "data"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { TransactionArgument, TransactionBlock, TransactionObjectArgument } from '@iota/iota-sdk/transactions';
|
|
2
|
+
import type { ObjectArgument } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a new shared Kiosk and returns the [kiosk, kioskOwnerCap] tuple.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createKiosk(tx: TransactionBlock): [TransactionObjectArgument, TransactionObjectArgument];
|
|
7
|
+
/**
|
|
8
|
+
* Calls the `kiosk::new()` function and shares the kiosk.
|
|
9
|
+
* Returns the `kioskOwnerCap` object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createKioskAndShare(tx: TransactionBlock): TransactionObjectArgument;
|
|
12
|
+
/**
|
|
13
|
+
* Converts Transfer Policy to a shared object.
|
|
14
|
+
*/
|
|
15
|
+
export declare function shareKiosk(tx: TransactionBlock, kiosk: TransactionArgument): void;
|
|
16
|
+
/**
|
|
17
|
+
* Call the `kiosk::place<T>(Kiosk, KioskOwnerCap, Item)` function.
|
|
18
|
+
* Place an item to the Kiosk.
|
|
19
|
+
*/
|
|
20
|
+
export declare function place(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, kioskCap: ObjectArgument, item: ObjectArgument): void;
|
|
21
|
+
/**
|
|
22
|
+
* Call the `kiosk::lock<T>(Kiosk, KioskOwnerCap, TransferPolicy, Item)`
|
|
23
|
+
* function. Lock an item in the Kiosk.
|
|
24
|
+
*
|
|
25
|
+
* Unlike `place` this function requires a `TransferPolicy` to exist
|
|
26
|
+
* and be passed in. This is done to make sure the item does not get
|
|
27
|
+
* locked without an option to take it out.
|
|
28
|
+
*/
|
|
29
|
+
export declare function lock(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, kioskCap: ObjectArgument, policy: ObjectArgument, item: ObjectArgument): void;
|
|
30
|
+
/**
|
|
31
|
+
* Call the `kiosk::take<T>(Kiosk, KioskOwnerCap, ID)` function.
|
|
32
|
+
* Take an item from the Kiosk.
|
|
33
|
+
*/
|
|
34
|
+
export declare function take(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, kioskCap: ObjectArgument, itemId: string): TransactionObjectArgument;
|
|
35
|
+
/**
|
|
36
|
+
* Call the `kiosk::list<T>(Kiosk, KioskOwnerCap, ID, u64)` function.
|
|
37
|
+
* List an item for sale.
|
|
38
|
+
*/
|
|
39
|
+
export declare function list(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, kioskCap: ObjectArgument, itemId: string, price: string | bigint): void;
|
|
40
|
+
/**
|
|
41
|
+
* Call the `kiosk::list<T>(Kiosk, KioskOwnerCap, ID, u64)` function.
|
|
42
|
+
* List an item for sale.
|
|
43
|
+
*/
|
|
44
|
+
export declare function delist(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, kioskCap: ObjectArgument, itemId: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Call the `kiosk::place_and_list<T>(Kiosk, KioskOwnerCap, Item, u64)` function.
|
|
47
|
+
* Place an item to the Kiosk and list it for sale.
|
|
48
|
+
*/
|
|
49
|
+
export declare function placeAndList(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, kioskCap: ObjectArgument, item: ObjectArgument, price: string | bigint): void;
|
|
50
|
+
/**
|
|
51
|
+
* Call the `kiosk::purchase<T>(Kiosk, ID, Coin<IOTA>)` function and receive an Item and
|
|
52
|
+
* a TransferRequest which needs to be dealt with (via a matching TransferPolicy).
|
|
53
|
+
*/
|
|
54
|
+
export declare function purchase(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, itemId: string, payment: ObjectArgument): [TransactionObjectArgument, TransactionObjectArgument];
|
|
55
|
+
/**
|
|
56
|
+
* Call the `kiosk::withdraw(Kiosk, KioskOwnerCap, Option<u64>)` function and receive a Coin<IOTA>.
|
|
57
|
+
* If the amount is null, then the entire balance will be withdrawn.
|
|
58
|
+
*/
|
|
59
|
+
export declare function withdrawFromKiosk(tx: TransactionBlock, kiosk: ObjectArgument, kioskCap: ObjectArgument, amount?: string | bigint | number): TransactionObjectArgument;
|
|
60
|
+
/**
|
|
61
|
+
* Call the `kiosk::borrow_value<T>(Kiosk, KioskOwnerCap, ID): T` function.
|
|
62
|
+
* Immutably borrow an item from the Kiosk and return it in the end.
|
|
63
|
+
*
|
|
64
|
+
* Requires calling `returnValue` to return the item.
|
|
65
|
+
*/
|
|
66
|
+
export declare function borrowValue(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, kioskCap: ObjectArgument, itemId: string): [TransactionArgument, TransactionArgument];
|
|
67
|
+
/**
|
|
68
|
+
* Call the `kiosk::return_value<T>(Kiosk, Item, Borrow)` function.
|
|
69
|
+
* Return an item to the Kiosk after it was `borrowValue`-d.
|
|
70
|
+
*/
|
|
71
|
+
export declare function returnValue(tx: TransactionBlock, itemType: string, kiosk: ObjectArgument, item: TransactionArgument, promise: TransactionArgument): void;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var kiosk_exports = {};
|
|
20
|
+
__export(kiosk_exports, {
|
|
21
|
+
borrowValue: () => borrowValue,
|
|
22
|
+
createKiosk: () => createKiosk,
|
|
23
|
+
createKioskAndShare: () => createKioskAndShare,
|
|
24
|
+
delist: () => delist,
|
|
25
|
+
list: () => list,
|
|
26
|
+
lock: () => lock,
|
|
27
|
+
place: () => place,
|
|
28
|
+
placeAndList: () => placeAndList,
|
|
29
|
+
purchase: () => purchase,
|
|
30
|
+
returnValue: () => returnValue,
|
|
31
|
+
shareKiosk: () => shareKiosk,
|
|
32
|
+
take: () => take,
|
|
33
|
+
withdrawFromKiosk: () => withdrawFromKiosk
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(kiosk_exports);
|
|
36
|
+
var import_bcs = require("@iota/iota-sdk/bcs");
|
|
37
|
+
var import_types = require("../types/index.js");
|
|
38
|
+
function createKiosk(tx) {
|
|
39
|
+
const [kiosk, kioskOwnerCap] = tx.moveCall({
|
|
40
|
+
target: `${import_types.KIOSK_MODULE}::new`
|
|
41
|
+
});
|
|
42
|
+
return [kiosk, kioskOwnerCap];
|
|
43
|
+
}
|
|
44
|
+
function createKioskAndShare(tx) {
|
|
45
|
+
const [kiosk, kioskOwnerCap] = createKiosk(tx);
|
|
46
|
+
shareKiosk(tx, kiosk);
|
|
47
|
+
return kioskOwnerCap;
|
|
48
|
+
}
|
|
49
|
+
function shareKiosk(tx, kiosk) {
|
|
50
|
+
tx.moveCall({
|
|
51
|
+
target: `0x2::transfer::public_share_object`,
|
|
52
|
+
typeArguments: [import_types.KIOSK_TYPE],
|
|
53
|
+
arguments: [kiosk]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function place(tx, itemType, kiosk, kioskCap, item) {
|
|
57
|
+
tx.moveCall({
|
|
58
|
+
target: `${import_types.KIOSK_MODULE}::place`,
|
|
59
|
+
typeArguments: [itemType],
|
|
60
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item)]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function lock(tx, itemType, kiosk, kioskCap, policy, item) {
|
|
64
|
+
tx.moveCall({
|
|
65
|
+
target: `${import_types.KIOSK_MODULE}::lock`,
|
|
66
|
+
typeArguments: [itemType],
|
|
67
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(policy), tx.object(item)]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function take(tx, itemType, kiosk, kioskCap, itemId) {
|
|
71
|
+
const [item] = tx.moveCall({
|
|
72
|
+
target: `${import_types.KIOSK_MODULE}::take`,
|
|
73
|
+
typeArguments: [itemType],
|
|
74
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
75
|
+
});
|
|
76
|
+
return item;
|
|
77
|
+
}
|
|
78
|
+
function list(tx, itemType, kiosk, kioskCap, itemId, price) {
|
|
79
|
+
tx.moveCall({
|
|
80
|
+
target: `${import_types.KIOSK_MODULE}::list`,
|
|
81
|
+
typeArguments: [itemType],
|
|
82
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId), tx.pure.u64(price)]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function delist(tx, itemType, kiosk, kioskCap, itemId) {
|
|
86
|
+
tx.moveCall({
|
|
87
|
+
target: `${import_types.KIOSK_MODULE}::delist`,
|
|
88
|
+
typeArguments: [itemType],
|
|
89
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function placeAndList(tx, itemType, kiosk, kioskCap, item, price) {
|
|
93
|
+
tx.moveCall({
|
|
94
|
+
target: `${import_types.KIOSK_MODULE}::place_and_list`,
|
|
95
|
+
typeArguments: [itemType],
|
|
96
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item), tx.pure.u64(price)]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function purchase(tx, itemType, kiosk, itemId, payment) {
|
|
100
|
+
const [item, transferRequest] = tx.moveCall({
|
|
101
|
+
target: `${import_types.KIOSK_MODULE}::purchase`,
|
|
102
|
+
typeArguments: [itemType],
|
|
103
|
+
arguments: [tx.object(kiosk), tx.pure.id(itemId), tx.object(payment)]
|
|
104
|
+
});
|
|
105
|
+
return [item, transferRequest];
|
|
106
|
+
}
|
|
107
|
+
function withdrawFromKiosk(tx, kiosk, kioskCap, amount) {
|
|
108
|
+
const amountArg = import_bcs.bcs.option(import_bcs.bcs.u64()).serialize(amount);
|
|
109
|
+
const [coin] = tx.moveCall({
|
|
110
|
+
target: `${import_types.KIOSK_MODULE}::withdraw`,
|
|
111
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), amountArg]
|
|
112
|
+
});
|
|
113
|
+
return coin;
|
|
114
|
+
}
|
|
115
|
+
function borrowValue(tx, itemType, kiosk, kioskCap, itemId) {
|
|
116
|
+
const [item, promise] = tx.moveCall({
|
|
117
|
+
target: `${import_types.KIOSK_MODULE}::borrow_val`,
|
|
118
|
+
typeArguments: [itemType],
|
|
119
|
+
arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)]
|
|
120
|
+
});
|
|
121
|
+
return [item, promise];
|
|
122
|
+
}
|
|
123
|
+
function returnValue(tx, itemType, kiosk, item, promise) {
|
|
124
|
+
tx.moveCall({
|
|
125
|
+
target: `${import_types.KIOSK_MODULE}::return_val`,
|
|
126
|
+
typeArguments: [itemType],
|
|
127
|
+
arguments: [tx.object(kiosk), item, promise]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=kiosk.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/tx/kiosk.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@iota/iota-sdk/bcs';\nimport type {\n TransactionArgument,\n TransactionBlock,\n TransactionObjectArgument,\n} from '@iota/iota-sdk/transactions';\n\nimport type { ObjectArgument } from '../types/index.js';\nimport { KIOSK_MODULE, KIOSK_TYPE } from '../types/index.js';\n\n/**\n * Create a new shared Kiosk and returns the [kiosk, kioskOwnerCap] tuple.\n */\nexport function createKiosk(\n tx: TransactionBlock,\n): [TransactionObjectArgument, TransactionObjectArgument] {\n const [kiosk, kioskOwnerCap] = tx.moveCall({\n target: `${KIOSK_MODULE}::new`,\n });\n\n return [kiosk, kioskOwnerCap];\n}\n\n/**\n * Calls the `kiosk::new()` function and shares the kiosk.\n * Returns the `kioskOwnerCap` object.\n */\nexport function createKioskAndShare(tx: TransactionBlock): TransactionObjectArgument {\n const [kiosk, kioskOwnerCap] = createKiosk(tx);\n shareKiosk(tx, kiosk);\n return kioskOwnerCap;\n}\n\n/**\n * Converts Transfer Policy to a shared object.\n */\nexport function shareKiosk(tx: TransactionBlock, kiosk: TransactionArgument) {\n tx.moveCall({\n target: `0x2::transfer::public_share_object`,\n typeArguments: [KIOSK_TYPE],\n arguments: [kiosk],\n });\n}\n\n/**\n * Call the `kiosk::place<T>(Kiosk, KioskOwnerCap, Item)` function.\n * Place an item to the Kiosk.\n */\nexport function place(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n kioskCap: ObjectArgument,\n item: ObjectArgument,\n): void {\n tx.moveCall({\n target: `${KIOSK_MODULE}::place`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item)],\n });\n}\n\n/**\n * Call the `kiosk::lock<T>(Kiosk, KioskOwnerCap, TransferPolicy, Item)`\n * function. Lock an item in the Kiosk.\n *\n * Unlike `place` this function requires a `TransferPolicy` to exist\n * and be passed in. This is done to make sure the item does not get\n * locked without an option to take it out.\n */\nexport function lock(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n kioskCap: ObjectArgument,\n policy: ObjectArgument,\n item: ObjectArgument,\n): void {\n tx.moveCall({\n target: `${KIOSK_MODULE}::lock`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(policy), tx.object(item)],\n });\n}\n\n/**\n * Call the `kiosk::take<T>(Kiosk, KioskOwnerCap, ID)` function.\n * Take an item from the Kiosk.\n */\nexport function take(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n kioskCap: ObjectArgument,\n itemId: string,\n): TransactionObjectArgument {\n const [item] = tx.moveCall({\n target: `${KIOSK_MODULE}::take`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)],\n });\n\n return item;\n}\n\n/**\n * Call the `kiosk::list<T>(Kiosk, KioskOwnerCap, ID, u64)` function.\n * List an item for sale.\n */\nexport function list(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n kioskCap: ObjectArgument,\n itemId: string,\n price: string | bigint,\n): void {\n tx.moveCall({\n target: `${KIOSK_MODULE}::list`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId), tx.pure.u64(price)],\n });\n}\n\n/**\n * Call the `kiosk::list<T>(Kiosk, KioskOwnerCap, ID, u64)` function.\n * List an item for sale.\n */\nexport function delist(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n kioskCap: ObjectArgument,\n itemId: string,\n): void {\n tx.moveCall({\n target: `${KIOSK_MODULE}::delist`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)],\n });\n}\n\n/**\n * Call the `kiosk::place_and_list<T>(Kiosk, KioskOwnerCap, Item, u64)` function.\n * Place an item to the Kiosk and list it for sale.\n */\nexport function placeAndList(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n kioskCap: ObjectArgument,\n item: ObjectArgument,\n price: string | bigint,\n): void {\n tx.moveCall({\n target: `${KIOSK_MODULE}::place_and_list`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), tx.object(kioskCap), tx.object(item), tx.pure.u64(price)],\n });\n}\n\n/**\n * Call the `kiosk::purchase<T>(Kiosk, ID, Coin<IOTA>)` function and receive an Item and\n * a TransferRequest which needs to be dealt with (via a matching TransferPolicy).\n */\nexport function purchase(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n itemId: string,\n payment: ObjectArgument,\n): [TransactionObjectArgument, TransactionObjectArgument] {\n const [item, transferRequest] = tx.moveCall({\n target: `${KIOSK_MODULE}::purchase`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), tx.pure.id(itemId), tx.object(payment)],\n });\n\n return [item, transferRequest];\n}\n\n/**\n * Call the `kiosk::withdraw(Kiosk, KioskOwnerCap, Option<u64>)` function and receive a Coin<IOTA>.\n * If the amount is null, then the entire balance will be withdrawn.\n */\nexport function withdrawFromKiosk(\n tx: TransactionBlock,\n kiosk: ObjectArgument,\n kioskCap: ObjectArgument,\n amount?: string | bigint | number,\n): TransactionObjectArgument {\n const amountArg = bcs.option(bcs.u64()).serialize(amount);\n\n const [coin] = tx.moveCall({\n target: `${KIOSK_MODULE}::withdraw`,\n arguments: [tx.object(kiosk), tx.object(kioskCap), amountArg],\n });\n\n return coin;\n}\n\n/**\n * Call the `kiosk::borrow_value<T>(Kiosk, KioskOwnerCap, ID): T` function.\n * Immutably borrow an item from the Kiosk and return it in the end.\n *\n * Requires calling `returnValue` to return the item.\n */\nexport function borrowValue(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n kioskCap: ObjectArgument,\n itemId: string,\n): [TransactionArgument, TransactionArgument] {\n const [item, promise] = tx.moveCall({\n target: `${KIOSK_MODULE}::borrow_val`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), tx.object(kioskCap), tx.pure.id(itemId)],\n });\n\n return [item, promise];\n}\n\n/**\n * Call the `kiosk::return_value<T>(Kiosk, Item, Borrow)` function.\n * Return an item to the Kiosk after it was `borrowValue`-d.\n */\nexport function returnValue(\n tx: TransactionBlock,\n itemType: string,\n kiosk: ObjectArgument,\n item: TransactionArgument,\n promise: TransactionArgument,\n): void {\n tx.moveCall({\n target: `${KIOSK_MODULE}::return_val`,\n typeArguments: [itemType],\n arguments: [tx.object(kiosk), item, promise],\n });\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransactionBlock, TransactionObjectArgument } from '@iota/iota-sdk/transactions';
|
|
2
|
+
import type { ObjectArgument } from '../types/index.js';
|
|
3
|
+
export declare function convertToPersonalTx(tx: TransactionBlock, kiosk: ObjectArgument, kioskOwnerCap: ObjectArgument, packageId: string): TransactionObjectArgument;
|
|
4
|
+
/**
|
|
5
|
+
* Transfers the personal kiosk Cap to the sender.
|
|
6
|
+
*/
|
|
7
|
+
export declare function transferPersonalCapTx(tx: TransactionBlock, personalKioskCap: TransactionObjectArgument, packageId: string): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var personal_kiosk_exports = {};
|
|
20
|
+
__export(personal_kiosk_exports, {
|
|
21
|
+
convertToPersonalTx: () => convertToPersonalTx,
|
|
22
|
+
transferPersonalCapTx: () => transferPersonalCapTx
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(personal_kiosk_exports);
|
|
25
|
+
function convertToPersonalTx(tx, kiosk, kioskOwnerCap, packageId) {
|
|
26
|
+
const personalKioskCap = tx.moveCall({
|
|
27
|
+
target: `${packageId}::personal_kiosk::new`,
|
|
28
|
+
arguments: [tx.object(kiosk), tx.object(kioskOwnerCap)]
|
|
29
|
+
});
|
|
30
|
+
return personalKioskCap;
|
|
31
|
+
}
|
|
32
|
+
function transferPersonalCapTx(tx, personalKioskCap, packageId) {
|
|
33
|
+
tx.moveCall({
|
|
34
|
+
target: `${packageId}::personal_kiosk::transfer_to_sender`,
|
|
35
|
+
arguments: [personalKioskCap]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=personal-kiosk.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/tx/personal-kiosk.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TransactionBlock, TransactionObjectArgument } from '@iota/iota-sdk/transactions';\n\nimport type { ObjectArgument } from '../types/index.js';\n\nexport function convertToPersonalTx(\n tx: TransactionBlock,\n kiosk: ObjectArgument,\n kioskOwnerCap: ObjectArgument,\n packageId: string,\n): TransactionObjectArgument {\n const personalKioskCap = tx.moveCall({\n target: `${packageId}::personal_kiosk::new`,\n arguments: [tx.object(kiosk), tx.object(kioskOwnerCap)],\n });\n\n return personalKioskCap;\n}\n\n/**\n * Transfers the personal kiosk Cap to the sender.\n */\nexport function transferPersonalCapTx(\n tx: TransactionBlock,\n personalKioskCap: TransactionObjectArgument,\n packageId: string,\n) {\n tx.moveCall({\n target: `${packageId}::personal_kiosk::transfer_to_sender`,\n arguments: [personalKioskCap],\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,oBACZ,IACA,OACA,eACA,WACyB;AACzB,QAAM,mBAAmB,GAAG,SAAS;AAAA,IACjC,QAAQ,GAAG;AAAA,IACX,WAAW,CAAC,GAAG,OAAO,KAAK,GAAG,GAAG,OAAO,aAAa,CAAC;AAAA,EAC1D,CAAC;AAED,SAAO;AACX;AAKO,SAAS,sBACZ,IACA,kBACA,WACF;AACE,KAAG,SAAS;AAAA,IACR,QAAQ,GAAG;AAAA,IACX,WAAW,CAAC,gBAAgB;AAAA,EAChC,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransactionBlock } from '@iota/iota-sdk/transactions';
|
|
2
|
+
import type { ObjectArgument } from '../../types/index.js';
|
|
3
|
+
export declare function attachKioskLockRuleTx(tx: TransactionBlock, type: string, policy: ObjectArgument, policyCap: ObjectArgument, packageId: string): void;
|
|
4
|
+
export declare function attachRoyaltyRuleTx(tx: TransactionBlock, type: string, policy: ObjectArgument, policyCap: ObjectArgument, percentageBps: number | string, // this is in basis points.
|
|
5
|
+
minAmount: number | string, packageId: string): void;
|
|
6
|
+
export declare function attachPersonalKioskRuleTx(tx: TransactionBlock, type: string, policy: ObjectArgument, policyCap: ObjectArgument, packageId: string): void;
|
|
7
|
+
export declare function attachFloorPriceRuleTx(tx: TransactionBlock, type: string, policy: ObjectArgument, policyCap: ObjectArgument, minPrice: string | bigint, packageId: string): void;
|