@mysten/kiosk 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/client/kiosk-client.d.mts +4 -4
- package/dist/client/kiosk-client.d.mts.map +1 -1
- package/dist/client/kiosk-client.mjs.map +1 -1
- package/dist/contracts/0x2/bag.mjs.map +1 -1
- package/dist/contracts/0x2/balance.mjs +1 -5
- package/dist/contracts/0x2/balance.mjs.map +1 -1
- package/dist/contracts/0x2/kiosk.mjs +5 -5
- package/dist/contracts/0x2/kiosk.mjs.map +1 -1
- package/dist/contracts/0x2/kiosk_extension.mjs +1 -1
- package/dist/contracts/0x2/kiosk_extension.mjs.map +1 -1
- package/dist/contracts/0x2/transfer_policy.mjs +6 -6
- package/dist/contracts/0x2/transfer_policy.mjs.map +1 -1
- package/dist/contracts/0x2/vec_set.mjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/query/client-utils.mjs +186 -1
- package/dist/query/client-utils.mjs.map +1 -1
- package/dist/query/kiosk.mjs +2 -1
- package/dist/query/kiosk.mjs.map +1 -1
- package/dist/query/transfer-policy.mjs +1 -1
- package/dist/query/transfer-policy.mjs.map +1 -1
- package/dist/types/index.d.mts +7 -4
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/kiosk.d.mts +13 -3
- package/dist/types/kiosk.d.mts.map +1 -1
- package/dist/types/kiosk.mjs.map +1 -1
- package/dist/utils.d.mts +3 -9
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +5 -24
- package/dist/utils.mjs.map +1 -1
- package/package.json +8 -7
- package/src/client/kiosk-client.ts +4 -3
- package/src/contracts/0x2/bag.ts +2 -181
- package/src/contracts/0x2/balance.ts +3 -260
- package/src/contracts/0x2/kiosk.ts +4 -4
- package/src/contracts/0x2/kiosk_extension.ts +1 -1
- package/src/contracts/0x2/transfer_policy.ts +6 -6
- package/src/contracts/0x2/vec_set.ts +1 -198
- package/src/contracts/kiosk/witness_rule.ts +1 -1
- package/src/query/client-utils.ts +253 -2
- package/src/query/kiosk.ts +3 -2
- package/src/query/transfer-policy.ts +4 -5
- package/src/types/index.ts +6 -2
- package/src/types/kiosk.ts +15 -3
- package/src/utils.ts +8 -38
- package/src/contracts/0x2/accumulator.ts +0 -24
- package/src/contracts/0x2/accumulator_metadata.ts +0 -38
- package/src/contracts/0x2/accumulator_settlement.ts +0 -14
- package/src/contracts/0x2/address.ts +0 -145
- package/src/contracts/0x2/address_alias.ts +0 -92
- package/src/contracts/0x2/authenticator_state.ts +0 -44
- package/src/contracts/0x2/bcs.ts +0 -495
- package/src/contracts/0x2/bls12381.ts +0 -717
- package/src/contracts/0x2/borrow.ts +0 -99
- package/src/contracts/0x2/clock.ts +0 -30
- package/src/contracts/0x2/coin.ts +0 -977
- package/src/contracts/0x2/coin_registry.ts +0 -874
- package/src/contracts/0x2/config.ts +0 -30
- package/src/contracts/0x2/deny_list.ts +0 -55
- package/src/contracts/0x2/derived_object.ts +0 -95
- package/src/contracts/0x2/display.ts +0 -258
- package/src/contracts/0x2/dynamic_field.ts +0 -171
- package/src/contracts/0x2/dynamic_object_field.ts +0 -167
- package/src/contracts/0x2/ecdsa_k1.ts +0 -65
- package/src/contracts/0x2/ecdsa_r1.ts +0 -49
- package/src/contracts/0x2/ecvrf.ts +0 -29
- package/src/contracts/0x2/ed25519.ts +0 -25
- package/src/contracts/0x2/event.ts +0 -42
- package/src/contracts/0x2/funds_accumulator.ts +0 -86
- package/src/contracts/0x2/groth16.ts +0 -171
- package/src/contracts/0x2/group_ops.ts +0 -49
- package/src/contracts/0x2/hash.ts +0 -37
- package/src/contracts/0x2/hex.ts +0 -37
- package/src/contracts/0x2/hmac.ts +0 -21
- package/src/contracts/0x2/linked_table.ts +0 -354
- package/src/contracts/0x2/math.ts +0 -117
- package/src/contracts/0x2/nitro_attestation.ts +0 -186
- package/src/contracts/0x2/object.ts +0 -249
- package/src/contracts/0x2/object_bag.ts +0 -210
- package/src/contracts/0x2/object_table.ts +0 -200
- package/src/contracts/0x2/package.ts +0 -414
- package/src/contracts/0x2/party.ts +0 -37
- package/src/contracts/0x2/pay.ts +0 -153
- package/src/contracts/0x2/poseidon.ts +0 -21
- package/src/contracts/0x2/priority_queue.ts +0 -139
- package/src/contracts/0x2/random.ts +0 -294
- package/src/contracts/0x2/sui.ts +0 -29
- package/src/contracts/0x2/table.ts +0 -200
- package/src/contracts/0x2/table_vec.ts +0 -232
- package/src/contracts/0x2/token.ts +0 -873
- package/src/contracts/0x2/transfer.ts +0 -216
- package/src/contracts/0x2/tx_context.ts +0 -129
- package/src/contracts/0x2/types.ts +0 -24
- package/src/contracts/0x2/url.ts +0 -77
- package/src/contracts/0x2/vdf.ts +0 -45
- package/src/contracts/0x2/vec_map.ts +0 -401
- package/src/contracts/0x2/versioned.ts +0 -153
- package/src/contracts/0x2/zklogin_verified_id.ts +0 -172
- package/src/contracts/0x2/zklogin_verified_issuer.ts +0 -99
- package/src/contracts/kiosk/deps/sui/object.ts +0 -15
package/dist/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":["KioskStruct"],"sources":["../src/utils.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { PaginationArguments } from '@mysten/sui/jsonRpc';\nimport type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\nimport { normalizeStructTag, normalizeSuiAddress, parseStructTag } from '@mysten/sui/utils';\nimport { chunk } from '@mysten/utils';\n\nimport { Listing, Lock, Kiosk as KioskStruct } from './contracts/0x2/kiosk.js';\nimport type { Kiosk, KioskData, KioskListing } from './types/index.js';\n\nconst DEFAULT_QUERY_LIMIT = 50;\n\nexport type DynamicFieldInfo = SuiClientTypes.ListDynamicFieldsResponse['dynamicFields'][number];\n\nexport async function getKioskObject(client: ClientWithCoreApi, id: string): Promise<Kiosk> {\n\tconst { object } = await client.core.getObject({\n\t\tobjectId: id,\n\t\tinclude: { content: true },\n\t});\n\n\tif (!object.content) {\n\t\tthrow new Error(`Kiosk ${id} not found or has no content`);\n\t}\n\n\tconst parsed = KioskStruct.parse(object.content);\n\n\treturn {\n\t\tid: parsed.id,\n\t\tprofits: parsed.profits.value.toString(),\n\t\towner: parsed.owner,\n\t\titemCount: parsed.item_count,\n\t\tallowExtensions: parsed.allow_extensions,\n\t};\n}\n\n// helper to extract kiosk data from dynamic fields.\nexport function extractKioskData(\n\tdata: DynamicFieldInfo[],\n\tlistings: KioskListing[],\n\tlockedItemIds: string[],\n\tkioskId: string,\n): KioskData {\n\treturn data.reduce<KioskData>(\n\t\t(acc: KioskData, val: DynamicFieldInfo) => {\n\t\t\tconst type = val.name.type;\n\n\t\t\tconst parsedType = parseStructTag(type);\n\t\t\tconst baseType = `${normalizeSuiAddress(parsedType.address)}::${parsedType.module}::${parsedType.name}`;\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Item'\n\t\t\t) {\n\t\t\t\tacc.itemIds.push(val.fieldId);\n\t\t\t\tacc.items.push({\n\t\t\t\t\tobjectId: val.fieldId,\n\t\t\t\t\ttype: val.valueType,\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tkioskId,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Listing'\n\t\t\t) {\n\t\t\t\tconst parsed = Listing.parse(val.name.bcs);\n\n\t\t\t\tacc.listingIds.push(val.fieldId);\n\t\t\t\tlistings.push({\n\t\t\t\t\tobjectId: parsed.id,\n\t\t\t\t\tlistingId: val.fieldId,\n\t\t\t\t\tisExclusive: parsed.is_exclusive,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Lock'\n\t\t\t) {\n\t\t\t\tlockedItemIds?.push(Lock.parse(val.name.bcs).id);\n\t\t\t}\n\n\t\t\t// Check for ExtensionKey type\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk_extension::ExtensionKey'\n\t\t\t) {\n\t\t\t\tacc.extensions.push({\n\t\t\t\t\tobjectId: val.fieldId,\n\t\t\t\t\ttype: normalizeStructTag(parsedType.typeParams[0]),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn acc;\n\t\t},\n\t\t{ items: [], itemIds: [], listingIds: [], extensions: [] },\n\t);\n}\n\n/**\n * A helper that attaches the listing prices to kiosk listings.\n */\nexport function attachListingsAndPrices(\n\tkioskData: KioskData,\n\tlistings: KioskListing[],\n\tlistingObjects: SuiClientTypes.Object[],\n) {\n\tconst itemListings = listings.reduce<Record<string, KioskListing>>(\n\t\t(acc: Record<string, KioskListing>, item, idx) => {\n\t\t\tacc[item.objectId] = { ...item };\n\n\t\t\t// return in case we don't have any listing objects.\n\t\t\t// that's the case when we don't have the `listingPrices` included.\n\t\t\tif (listingObjects.length === 0) return acc;\n\n\t\t\tconst obj = listingObjects[idx];\n\n\t\t\t// Parse BCS content to extract the price (u64 value)\n\t\t\tif (obj.content) {\n\t\t\t\tacc[item.objectId].price = bcs.u64().parse(obj.content).toString();\n\t\t\t}\n\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\tkioskData.items.forEach((item) => {\n\t\titem.listing = itemListings[item.objectId] || undefined;\n\t});\n}\n\n/**\n * A helper that attaches object data to kiosk items.\n * Works with core API objects that contain BCS content.\n */\nexport function attachObjects(kioskData: KioskData, objects: SuiClientTypes.Object[]) {\n\tconst mapping = objects.reduce<Record<string, SuiClientTypes.Object>>(\n\t\t(acc: Record<string, SuiClientTypes.Object>, obj) => {\n\t\t\tacc[obj.objectId] = obj;\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\tkioskData.items.forEach((item) => {\n\t\titem.data = mapping[item.objectId] || undefined;\n\t});\n}\n\n/**\n * A Helper to attach locked state to items in Kiosk Data.\n */\nexport function attachLockedItems(kioskData: KioskData, lockedItemIds: string[]) {\n\t// map lock status in an array of type { item_id: true }\n\tconst lockedStatuses = lockedItemIds.reduce<Record<string, boolean>>(\n\t\t(acc: Record<string, boolean>, item: string) => {\n\t\t\tacc[item] = true;\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\t// parse lockedItemIds and attach their locked status.\n\tkioskData.items.forEach((item) => {\n\t\titem.isLocked = lockedStatuses[item.objectId] || false;\n\t});\n}\n\n/**\n * A helper to fetch all dynamic field pages.\n * We need that to fetch the kiosk DFs consistently, until we have\n * RPC calls that allow filtering of Type / batch fetching of spec\n */\nexport async function getAllDynamicFields(\n\tclient: ClientWithCoreApi,\n\tparentId: string,\n\tpagination: PaginationArguments<string>,\n): Promise<DynamicFieldInfo[]> {\n\tlet hasNextPage = true;\n\tlet cursor: string | null = null;\n\tconst data: DynamicFieldInfo[] = [];\n\n\twhile (hasNextPage) {\n\t\tconst result = await client.core.listDynamicFields({\n\t\t\tparentId,\n\t\t\tlimit: pagination.limit || undefined,\n\t\t\tcursor,\n\t\t});\n\n\t\tdata.push(...result.dynamicFields);\n\n\t\thasNextPage = result.hasNextPage;\n\t\tcursor = result.cursor;\n\t}\n\n\treturn data;\n}\n\n/**\n * A helper to fetch all objects that works with pagination.\n * It will fetch all objects in the array, and limit it to 50/request.\n * Requests are sent using `Promise.all`.\n */\nexport async function getAllObjects(\n\tclient: ClientWithCoreApi,\n\tids: string[],\n): Promise<SuiClientTypes.Object[]> {\n\tconst chunks = chunk(ids, DEFAULT_QUERY_LIMIT);\n\n\tconst results = await Promise.all(\n\t\tchunks.map(async (objectIds) => {\n\t\t\tconst { objects } = await client.core.getObjects({\n\t\t\t\tobjectIds,\n\t\t\t\tinclude: {\n\t\t\t\t\tcontent: true,\n\t\t\t\t\tpreviousTransaction: true,\n\t\t\t\t},\n\t\t\t});\n\n\t\t\treturn objects.filter((obj): obj is SuiClientTypes.Object => !(obj instanceof Error));\n\t\t}),\n\t);\n\n\treturn results.flat();\n}\n\n/**\n * Converts a number to basis points.\n * Supports up to 2 decimal points.\n * E.g 9.95 -> 995\n * @param percentage A percentage amount in the range [0, 100] including decimals.\n */\nexport function percentageToBasisPoints(percentage: number) {\n\tif (percentage < 0 || percentage > 100)\n\t\tthrow new Error('Percentage needs to be in the [0,100] range.');\n\treturn Math.ceil(percentage * 100);\n}\n\n// Normalizes the packageId part of a rule's type.\nexport function getNormalizedRuleType(rule: string) {\n\tconst normalizedRuleAddress = rule.split('::');\n\tnormalizedRuleAddress[0] = normalizeSuiAddress(normalizedRuleAddress[0]);\n\treturn normalizedRuleAddress.join('::');\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":["KioskStruct"],"sources":["../src/utils.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/sui/bcs';\nimport { PaginationArguments } from '@mysten/sui/jsonRpc';\nimport type { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\nimport { normalizeStructTag, normalizeSuiAddress, parseStructTag } from '@mysten/sui/utils';\n\nimport { Item, Listing, Lock, Kiosk as KioskStruct } from './contracts/0x2/kiosk.js';\nimport type { Kiosk, KioskData, KioskListing, ObjectWithDisplay } from './types/index.js';\n\nexport type DynamicFieldInfo = SuiClientTypes.ListDynamicFieldsResponse['dynamicFields'][number];\n\nexport async function getKioskObject(client: ClientWithCoreApi, id: string): Promise<Kiosk> {\n\tconst { object } = await client.core.getObject({\n\t\tobjectId: id,\n\t\tinclude: { content: true },\n\t});\n\n\tif (!object.content) {\n\t\tthrow new Error(`Kiosk ${id} not found or has no content`);\n\t}\n\n\tconst parsed = KioskStruct.parse(object.content);\n\n\treturn {\n\t\tid: parsed.id,\n\t\tprofits: parsed.profits.value.toString(),\n\t\towner: parsed.owner,\n\t\titemCount: parsed.item_count,\n\t\tallowExtensions: parsed.allow_extensions,\n\t};\n}\n\n// helper to extract kiosk data from dynamic fields.\nexport function extractKioskData(\n\tdata: DynamicFieldInfo[],\n\tlistings: KioskListing[],\n\tlockedItemIds: string[],\n\tkioskId: string,\n): KioskData {\n\treturn data.reduce<KioskData>(\n\t\t(acc: KioskData, val: DynamicFieldInfo) => {\n\t\t\tconst type = val.name.type;\n\n\t\t\tconst parsedType = parseStructTag(type);\n\t\t\tconst baseType = `${normalizeSuiAddress(parsedType.address)}::${parsedType.module}::${parsedType.name}`;\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Item'\n\t\t\t) {\n\t\t\t\tconst parsed = Item.parse(val.name.bcs);\n\t\t\t\tacc.itemIds.push(parsed.id);\n\t\t\t\tacc.items.push({\n\t\t\t\t\tobjectId: parsed.id,\n\t\t\t\t\ttype: val.valueType,\n\t\t\t\t\tisLocked: false,\n\t\t\t\t\tkioskId,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Listing'\n\t\t\t) {\n\t\t\t\tconst parsed = Listing.parse(val.name.bcs);\n\n\t\t\t\tacc.listingIds.push(val.fieldId);\n\t\t\t\tlistings.push({\n\t\t\t\t\tobjectId: parsed.id,\n\t\t\t\t\tlistingId: val.fieldId,\n\t\t\t\t\tisExclusive: parsed.is_exclusive,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk::Lock'\n\t\t\t) {\n\t\t\t\tlockedItemIds?.push(Lock.parse(val.name.bcs).id);\n\t\t\t}\n\n\t\t\t// Check for ExtensionKey type\n\t\t\tif (\n\t\t\t\tbaseType ===\n\t\t\t\t'0x0000000000000000000000000000000000000000000000000000000000000002::kiosk_extension::ExtensionKey'\n\t\t\t) {\n\t\t\t\tacc.extensions.push({\n\t\t\t\t\tobjectId: val.fieldId,\n\t\t\t\t\ttype: normalizeStructTag(parsedType.typeParams[0]),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn acc;\n\t\t},\n\t\t{ items: [], itemIds: [], listingIds: [], extensions: [] },\n\t);\n}\n\n/**\n * A helper that attaches the listing prices to kiosk listings.\n */\nexport function attachListingsAndPrices(\n\tkioskData: KioskData,\n\tlistings: KioskListing[],\n\tlistingObjects: SuiClientTypes.Object[],\n) {\n\tconst itemListings = listings.reduce<Record<string, KioskListing>>(\n\t\t(acc: Record<string, KioskListing>, item, idx) => {\n\t\t\tacc[item.objectId] = { ...item };\n\n\t\t\t// return in case we don't have any listing objects.\n\t\t\t// that's the case when we don't have the `listingPrices` included.\n\t\t\tif (listingObjects.length === 0) return acc;\n\n\t\t\tconst obj = listingObjects[idx];\n\n\t\t\t// Parse BCS content to extract the price (u64 value)\n\t\t\tif (obj.content) {\n\t\t\t\tacc[item.objectId].price = bcs.u64().parse(obj.content).toString();\n\t\t\t}\n\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\tkioskData.items.forEach((item) => {\n\t\titem.listing = itemListings[item.objectId] || undefined;\n\t});\n}\n\n/**\n * A helper that attaches object data to kiosk items.\n * Works with core API objects that contain BCS content.\n */\nexport function attachObjects(kioskData: KioskData, objects: ObjectWithDisplay[]) {\n\tconst mapping = objects.reduce<Record<string, ObjectWithDisplay>>(\n\t\t(acc: Record<string, ObjectWithDisplay>, obj) => {\n\t\t\tacc[obj.objectId] = obj;\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\tkioskData.items.forEach((item) => {\n\t\titem.data = mapping[item.objectId] || undefined;\n\t});\n}\n\n/**\n * A Helper to attach locked state to items in Kiosk Data.\n */\nexport function attachLockedItems(kioskData: KioskData, lockedItemIds: string[]) {\n\t// map lock status in an array of type { item_id: true }\n\tconst lockedStatuses = lockedItemIds.reduce<Record<string, boolean>>(\n\t\t(acc: Record<string, boolean>, item: string) => {\n\t\t\tacc[item] = true;\n\t\t\treturn acc;\n\t\t},\n\t\t{},\n\t);\n\n\t// parse lockedItemIds and attach their locked status.\n\tkioskData.items.forEach((item) => {\n\t\titem.isLocked = lockedStatuses[item.objectId] || false;\n\t});\n}\n\n/**\n * A helper to fetch all dynamic field pages.\n * We need that to fetch the kiosk DFs consistently, until we have\n * RPC calls that allow filtering of Type / batch fetching of spec\n */\nexport async function getAllDynamicFields(\n\tclient: ClientWithCoreApi,\n\tparentId: string,\n\tpagination: PaginationArguments<string>,\n): Promise<DynamicFieldInfo[]> {\n\tlet hasNextPage = true;\n\tlet cursor: string | null = null;\n\tconst data: DynamicFieldInfo[] = [];\n\n\twhile (hasNextPage) {\n\t\tconst result = await client.core.listDynamicFields({\n\t\t\tparentId,\n\t\t\tlimit: pagination.limit || undefined,\n\t\t\tcursor,\n\t\t});\n\n\t\tdata.push(...result.dynamicFields);\n\n\t\thasNextPage = result.hasNextPage;\n\t\tcursor = result.cursor;\n\t}\n\n\treturn data;\n}\n\n/**\n * Converts a number to basis points.\n * Supports up to 2 decimal points.\n * E.g 9.95 -> 995\n * @param percentage A percentage amount in the range [0, 100] including decimals.\n */\nexport function percentageToBasisPoints(percentage: number) {\n\tif (percentage < 0 || percentage > 100)\n\t\tthrow new Error('Percentage needs to be in the [0,100] range.');\n\treturn Math.ceil(percentage * 100);\n}\n\n// Normalizes the packageId part of a rule's type.\nexport function getNormalizedRuleType(rule: string) {\n\tconst normalizedRuleAddress = rule.split('::');\n\tnormalizedRuleAddress[0] = normalizeSuiAddress(normalizedRuleAddress[0]);\n\treturn normalizedRuleAddress.join('::');\n}\n"],"mappings":";;;;;AAaA,eAAsB,eAAe,QAA2B,IAA4B;CAC3F,MAAM,EAAE,WAAW,MAAM,OAAO,KAAK,UAAU;EAC9C,UAAU;EACV,SAAS,EAAE,SAAS,MAAM;EAC1B,CAAC;AAEF,KAAI,CAAC,OAAO,QACX,OAAM,IAAI,MAAM,SAAS,GAAG,8BAA8B;CAG3D,MAAM,SAASA,MAAY,MAAM,OAAO,QAAQ;AAEhD,QAAO;EACN,IAAI,OAAO;EACX,SAAS,OAAO,QAAQ,MAAM,UAAU;EACxC,OAAO,OAAO;EACd,WAAW,OAAO;EAClB,iBAAiB,OAAO;EACxB;;AAIF,SAAgB,iBACf,MACA,UACA,eACA,SACY;AACZ,QAAO,KAAK,QACV,KAAgB,QAA0B;EAC1C,MAAM,OAAO,IAAI,KAAK;EAEtB,MAAM,aAAa,eAAe,KAAK;EACvC,MAAM,WAAW,GAAG,oBAAoB,WAAW,QAAQ,CAAC,IAAI,WAAW,OAAO,IAAI,WAAW;AAEjG,MACC,aACA,mFACC;GACD,MAAM,SAAS,KAAK,MAAM,IAAI,KAAK,IAAI;AACvC,OAAI,QAAQ,KAAK,OAAO,GAAG;AAC3B,OAAI,MAAM,KAAK;IACd,UAAU,OAAO;IACjB,MAAM,IAAI;IACV,UAAU;IACV;IACA,CAAC;;AAGH,MACC,aACA,sFACC;GACD,MAAM,SAAS,QAAQ,MAAM,IAAI,KAAK,IAAI;AAE1C,OAAI,WAAW,KAAK,IAAI,QAAQ;AAChC,YAAS,KAAK;IACb,UAAU,OAAO;IACjB,WAAW,IAAI;IACf,aAAa,OAAO;IACpB,CAAC;;AAGH,MACC,aACA,kFAEA,gBAAe,KAAK,KAAK,MAAM,IAAI,KAAK,IAAI,CAAC,GAAG;AAIjD,MACC,aACA,oGAEA,KAAI,WAAW,KAAK;GACnB,UAAU,IAAI;GACd,MAAM,mBAAmB,WAAW,WAAW,GAAG;GAClD,CAAC;AAGH,SAAO;IAER;EAAE,OAAO,EAAE;EAAE,SAAS,EAAE;EAAE,YAAY,EAAE;EAAE,YAAY,EAAE;EAAE,CAC1D;;;;;AAMF,SAAgB,wBACf,WACA,UACA,gBACC;CACD,MAAM,eAAe,SAAS,QAC5B,KAAmC,MAAM,QAAQ;AACjD,MAAI,KAAK,YAAY,EAAE,GAAG,MAAM;AAIhC,MAAI,eAAe,WAAW,EAAG,QAAO;EAExC,MAAM,MAAM,eAAe;AAG3B,MAAI,IAAI,QACP,KAAI,KAAK,UAAU,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU;AAGnE,SAAO;IAER,EAAE,CACF;AAED,WAAU,MAAM,SAAS,SAAS;AACjC,OAAK,UAAU,aAAa,KAAK,aAAa;GAC7C;;;;;;AAOH,SAAgB,cAAc,WAAsB,SAA8B;CACjF,MAAM,UAAU,QAAQ,QACtB,KAAwC,QAAQ;AAChD,MAAI,IAAI,YAAY;AACpB,SAAO;IAER,EAAE,CACF;AAED,WAAU,MAAM,SAAS,SAAS;AACjC,OAAK,OAAO,QAAQ,KAAK,aAAa;GACrC;;;;;AAMH,SAAgB,kBAAkB,WAAsB,eAAyB;CAEhF,MAAM,iBAAiB,cAAc,QACnC,KAA8B,SAAiB;AAC/C,MAAI,QAAQ;AACZ,SAAO;IAER,EAAE,CACF;AAGD,WAAU,MAAM,SAAS,SAAS;AACjC,OAAK,WAAW,eAAe,KAAK,aAAa;GAChD;;;;;;;AAQH,eAAsB,oBACrB,QACA,UACA,YAC8B;CAC9B,IAAI,cAAc;CAClB,IAAI,SAAwB;CAC5B,MAAM,OAA2B,EAAE;AAEnC,QAAO,aAAa;EACnB,MAAM,SAAS,MAAM,OAAO,KAAK,kBAAkB;GAClD;GACA,OAAO,WAAW,SAAS;GAC3B;GACA,CAAC;AAEF,OAAK,KAAK,GAAG,OAAO,cAAc;AAElC,gBAAc,OAAO;AACrB,WAAS,OAAO;;AAGjB,QAAO;;;;;;;;AASR,SAAgB,wBAAwB,YAAoB;AAC3D,KAAI,aAAa,KAAK,aAAa,IAClC,OAAM,IAAI,MAAM,+CAA+C;AAChE,QAAO,KAAK,KAAK,aAAa,IAAI;;AAInC,SAAgB,sBAAsB,MAAc;CACnD,MAAM,wBAAwB,KAAK,MAAM,KAAK;AAC9C,uBAAsB,KAAK,oBAAoB,sBAAsB,GAAG;AACxE,QAAO,sBAAsB,KAAK,KAAK"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@mysten/kiosk",
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui Kiosk library",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.1.1",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.mjs",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/index.d.mts",
|
|
13
|
-
"import": "./dist/index.mjs"
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
16
17
|
"sideEffects": false,
|
|
@@ -30,8 +31,8 @@
|
|
|
30
31
|
"url": "https://github.com/MystenLabs/ts-sdks/issues/new"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@mysten/bcs": "^2.0.
|
|
34
|
-
"@mysten/utils": "^0.3.
|
|
34
|
+
"@mysten/bcs": "^2.0.2",
|
|
35
|
+
"@mysten/utils": "^0.3.1"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"cross-env": "^10.1.0",
|
|
@@ -41,11 +42,11 @@
|
|
|
41
42
|
"vite": "^7.3.1",
|
|
42
43
|
"vitest": "^4.0.17",
|
|
43
44
|
"wait-on": "^9.0.3",
|
|
44
|
-
"@mysten/codegen": "^0.
|
|
45
|
-
"@mysten/sui": "^2.
|
|
45
|
+
"@mysten/codegen": "^0.8.1",
|
|
46
|
+
"@mysten/sui": "^2.3.2"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
|
-
"@mysten/sui": "^2.
|
|
49
|
+
"@mysten/sui": "^2.3.2"
|
|
49
50
|
},
|
|
50
51
|
"scripts": {
|
|
51
52
|
"build": "rm -rf dist && tsc --noEmit && tsdown",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { PaginationArguments } from '@mysten/sui/jsonRpc';
|
|
5
|
-
import type {
|
|
5
|
+
import type { SuiClientTypes } from '@mysten/sui/client';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
FLOOR_PRICE_RULE_ADDRESS,
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import type {
|
|
23
23
|
FetchKioskOptions,
|
|
24
24
|
KioskClientOptions,
|
|
25
|
+
KioskCompatibleClient,
|
|
25
26
|
KioskData,
|
|
26
27
|
OwnedKiosks,
|
|
27
28
|
} from '../types/index.js';
|
|
@@ -53,7 +54,7 @@ export function kiosk<const Name extends string = 'kiosk'>({
|
|
|
53
54
|
}: KioskExtensionOptions<Name> = {}) {
|
|
54
55
|
return {
|
|
55
56
|
name,
|
|
56
|
-
register: (client:
|
|
57
|
+
register: (client: KioskCompatibleClient) => {
|
|
57
58
|
return new KioskClient({
|
|
58
59
|
client,
|
|
59
60
|
network: client.network,
|
|
@@ -70,7 +71,7 @@ export function kiosk<const Name extends string = 'kiosk'>({
|
|
|
70
71
|
* If you pass packageIds, all functionality will be managed using these packages.
|
|
71
72
|
*/
|
|
72
73
|
export class KioskClient {
|
|
73
|
-
client:
|
|
74
|
+
client: KioskCompatibleClient;
|
|
74
75
|
network: SuiClientTypes.Network;
|
|
75
76
|
rules: TransferPolicyRule[];
|
|
76
77
|
packageIds?: BaseRulePackageIds;
|
package/src/contracts/0x2/bag.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**************************************************************
|
|
2
2
|
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
3
|
**************************************************************/
|
|
4
|
-
import { MoveStruct
|
|
5
|
-
import { bcs
|
|
6
|
-
import { type Transaction } from '@mysten/sui/transactions';
|
|
4
|
+
import { MoveStruct } from '../utils/index.js';
|
|
5
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
7
6
|
const $moduleName = '0x2::bag';
|
|
8
7
|
export const Bag = new MoveStruct({
|
|
9
8
|
name: `${$moduleName}::Bag`,
|
|
@@ -12,181 +11,3 @@ export const Bag = new MoveStruct({
|
|
|
12
11
|
size: bcs.u64(),
|
|
13
12
|
},
|
|
14
13
|
});
|
|
15
|
-
export interface NewOptions {
|
|
16
|
-
package?: string;
|
|
17
|
-
arguments?: [];
|
|
18
|
-
}
|
|
19
|
-
export function _new(options: NewOptions = {}) {
|
|
20
|
-
const packageAddress =
|
|
21
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
22
|
-
return (tx: Transaction) =>
|
|
23
|
-
tx.moveCall({
|
|
24
|
-
package: packageAddress,
|
|
25
|
-
module: 'bag',
|
|
26
|
-
function: 'new',
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
export interface AddOptions<T0 extends BcsType<any>, T1 extends BcsType<any>> {
|
|
30
|
-
package?: string;
|
|
31
|
-
arguments: [
|
|
32
|
-
RawTransactionArgument<string>,
|
|
33
|
-
RawTransactionArgument<T0>,
|
|
34
|
-
RawTransactionArgument<T1>,
|
|
35
|
-
];
|
|
36
|
-
typeArguments: [string, string];
|
|
37
|
-
}
|
|
38
|
-
export function add<T0 extends BcsType<any>, T1 extends BcsType<any>>(options: AddOptions<T0, T1>) {
|
|
39
|
-
const packageAddress =
|
|
40
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
41
|
-
const argumentsTypes = [
|
|
42
|
-
null,
|
|
43
|
-
`${options.typeArguments[0]}`,
|
|
44
|
-
`${options.typeArguments[1]}`,
|
|
45
|
-
] satisfies (string | null)[];
|
|
46
|
-
return (tx: Transaction) =>
|
|
47
|
-
tx.moveCall({
|
|
48
|
-
package: packageAddress,
|
|
49
|
-
module: 'bag',
|
|
50
|
-
function: 'add',
|
|
51
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
52
|
-
typeArguments: options.typeArguments,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
export interface BorrowOptions<T0 extends BcsType<any>> {
|
|
56
|
-
package?: string;
|
|
57
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];
|
|
58
|
-
typeArguments: [string, string];
|
|
59
|
-
}
|
|
60
|
-
export function borrow<T0 extends BcsType<any>>(options: BorrowOptions<T0>) {
|
|
61
|
-
const packageAddress =
|
|
62
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
63
|
-
const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[];
|
|
64
|
-
return (tx: Transaction) =>
|
|
65
|
-
tx.moveCall({
|
|
66
|
-
package: packageAddress,
|
|
67
|
-
module: 'bag',
|
|
68
|
-
function: 'borrow',
|
|
69
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
70
|
-
typeArguments: options.typeArguments,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
export interface BorrowMutOptions<T0 extends BcsType<any>> {
|
|
74
|
-
package?: string;
|
|
75
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];
|
|
76
|
-
typeArguments: [string, string];
|
|
77
|
-
}
|
|
78
|
-
export function borrowMut<T0 extends BcsType<any>>(options: BorrowMutOptions<T0>) {
|
|
79
|
-
const packageAddress =
|
|
80
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
81
|
-
const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[];
|
|
82
|
-
return (tx: Transaction) =>
|
|
83
|
-
tx.moveCall({
|
|
84
|
-
package: packageAddress,
|
|
85
|
-
module: 'bag',
|
|
86
|
-
function: 'borrow_mut',
|
|
87
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
88
|
-
typeArguments: options.typeArguments,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
export interface RemoveOptions<T0 extends BcsType<any>> {
|
|
92
|
-
package?: string;
|
|
93
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];
|
|
94
|
-
typeArguments: [string, string];
|
|
95
|
-
}
|
|
96
|
-
export function remove<T0 extends BcsType<any>>(options: RemoveOptions<T0>) {
|
|
97
|
-
const packageAddress =
|
|
98
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
99
|
-
const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[];
|
|
100
|
-
return (tx: Transaction) =>
|
|
101
|
-
tx.moveCall({
|
|
102
|
-
package: packageAddress,
|
|
103
|
-
module: 'bag',
|
|
104
|
-
function: 'remove',
|
|
105
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
106
|
-
typeArguments: options.typeArguments,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
export interface ContainsOptions<T0 extends BcsType<any>> {
|
|
110
|
-
package?: string;
|
|
111
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];
|
|
112
|
-
typeArguments: [string];
|
|
113
|
-
}
|
|
114
|
-
export function contains<T0 extends BcsType<any>>(options: ContainsOptions<T0>) {
|
|
115
|
-
const packageAddress =
|
|
116
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
117
|
-
const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[];
|
|
118
|
-
return (tx: Transaction) =>
|
|
119
|
-
tx.moveCall({
|
|
120
|
-
package: packageAddress,
|
|
121
|
-
module: 'bag',
|
|
122
|
-
function: 'contains',
|
|
123
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
124
|
-
typeArguments: options.typeArguments,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
export interface ContainsWithTypeOptions<T0 extends BcsType<any>> {
|
|
128
|
-
package?: string;
|
|
129
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<T0>];
|
|
130
|
-
typeArguments: [string, string];
|
|
131
|
-
}
|
|
132
|
-
export function containsWithType<T0 extends BcsType<any>>(options: ContainsWithTypeOptions<T0>) {
|
|
133
|
-
const packageAddress =
|
|
134
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
135
|
-
const argumentsTypes = [null, `${options.typeArguments[0]}`] satisfies (string | null)[];
|
|
136
|
-
return (tx: Transaction) =>
|
|
137
|
-
tx.moveCall({
|
|
138
|
-
package: packageAddress,
|
|
139
|
-
module: 'bag',
|
|
140
|
-
function: 'contains_with_type',
|
|
141
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
142
|
-
typeArguments: options.typeArguments,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
export interface LengthOptions {
|
|
146
|
-
package?: string;
|
|
147
|
-
arguments: [RawTransactionArgument<string>];
|
|
148
|
-
}
|
|
149
|
-
export function length(options: LengthOptions) {
|
|
150
|
-
const packageAddress =
|
|
151
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
152
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
153
|
-
return (tx: Transaction) =>
|
|
154
|
-
tx.moveCall({
|
|
155
|
-
package: packageAddress,
|
|
156
|
-
module: 'bag',
|
|
157
|
-
function: 'length',
|
|
158
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
export interface IsEmptyOptions {
|
|
162
|
-
package?: string;
|
|
163
|
-
arguments: [RawTransactionArgument<string>];
|
|
164
|
-
}
|
|
165
|
-
export function isEmpty(options: IsEmptyOptions) {
|
|
166
|
-
const packageAddress =
|
|
167
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
168
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
169
|
-
return (tx: Transaction) =>
|
|
170
|
-
tx.moveCall({
|
|
171
|
-
package: packageAddress,
|
|
172
|
-
module: 'bag',
|
|
173
|
-
function: 'is_empty',
|
|
174
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
export interface DestroyEmptyOptions {
|
|
178
|
-
package?: string;
|
|
179
|
-
arguments: [RawTransactionArgument<string>];
|
|
180
|
-
}
|
|
181
|
-
export function destroyEmpty(options: DestroyEmptyOptions) {
|
|
182
|
-
const packageAddress =
|
|
183
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
184
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
185
|
-
return (tx: Transaction) =>
|
|
186
|
-
tx.moveCall({
|
|
187
|
-
package: packageAddress,
|
|
188
|
-
module: 'bag',
|
|
189
|
-
function: 'destroy_empty',
|
|
190
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
191
|
-
});
|
|
192
|
-
}
|
|
@@ -1,269 +1,12 @@
|
|
|
1
1
|
/**************************************************************
|
|
2
2
|
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
3
|
**************************************************************/
|
|
4
|
-
import { MoveStruct
|
|
5
|
-
import { bcs
|
|
6
|
-
import { type Transaction } from '@mysten/sui/transactions';
|
|
4
|
+
import { MoveStruct } from '../utils/index.js';
|
|
5
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
7
6
|
const $moduleName = '0x2::balance';
|
|
8
|
-
export const Supply = new MoveStruct({
|
|
9
|
-
name: `${$moduleName}::Supply`,
|
|
10
|
-
fields: {
|
|
11
|
-
value: bcs.u64(),
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
7
|
export const Balance = new MoveStruct({
|
|
15
|
-
name: `${$moduleName}::Balance
|
|
8
|
+
name: `${$moduleName}::Balance<phantom T0>`,
|
|
16
9
|
fields: {
|
|
17
10
|
value: bcs.u64(),
|
|
18
11
|
},
|
|
19
12
|
});
|
|
20
|
-
export interface ValueOptions {
|
|
21
|
-
package?: string;
|
|
22
|
-
arguments: [RawTransactionArgument<string>];
|
|
23
|
-
typeArguments: [string];
|
|
24
|
-
}
|
|
25
|
-
export function value(options: ValueOptions) {
|
|
26
|
-
const packageAddress =
|
|
27
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
28
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
29
|
-
return (tx: Transaction) =>
|
|
30
|
-
tx.moveCall({
|
|
31
|
-
package: packageAddress,
|
|
32
|
-
module: 'balance',
|
|
33
|
-
function: 'value',
|
|
34
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
35
|
-
typeArguments: options.typeArguments,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
export interface SupplyValueOptions {
|
|
39
|
-
package?: string;
|
|
40
|
-
arguments: [RawTransactionArgument<string>];
|
|
41
|
-
typeArguments: [string];
|
|
42
|
-
}
|
|
43
|
-
export function supplyValue(options: SupplyValueOptions) {
|
|
44
|
-
const packageAddress =
|
|
45
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
46
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
47
|
-
return (tx: Transaction) =>
|
|
48
|
-
tx.moveCall({
|
|
49
|
-
package: packageAddress,
|
|
50
|
-
module: 'balance',
|
|
51
|
-
function: 'supply_value',
|
|
52
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
53
|
-
typeArguments: options.typeArguments,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
export interface CreateSupplyOptions<T0 extends BcsType<any>> {
|
|
57
|
-
package?: string;
|
|
58
|
-
arguments: [RawTransactionArgument<T0>];
|
|
59
|
-
typeArguments: [string];
|
|
60
|
-
}
|
|
61
|
-
export function createSupply<T0 extends BcsType<any>>(options: CreateSupplyOptions<T0>) {
|
|
62
|
-
const packageAddress =
|
|
63
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
64
|
-
const argumentsTypes = [`${options.typeArguments[0]}`] satisfies (string | null)[];
|
|
65
|
-
return (tx: Transaction) =>
|
|
66
|
-
tx.moveCall({
|
|
67
|
-
package: packageAddress,
|
|
68
|
-
module: 'balance',
|
|
69
|
-
function: 'create_supply',
|
|
70
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
71
|
-
typeArguments: options.typeArguments,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
export interface IncreaseSupplyOptions {
|
|
75
|
-
package?: string;
|
|
76
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<number | bigint>];
|
|
77
|
-
typeArguments: [string];
|
|
78
|
-
}
|
|
79
|
-
export function increaseSupply(options: IncreaseSupplyOptions) {
|
|
80
|
-
const packageAddress =
|
|
81
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
82
|
-
const argumentsTypes = [null, 'u64'] satisfies (string | null)[];
|
|
83
|
-
return (tx: Transaction) =>
|
|
84
|
-
tx.moveCall({
|
|
85
|
-
package: packageAddress,
|
|
86
|
-
module: 'balance',
|
|
87
|
-
function: 'increase_supply',
|
|
88
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
89
|
-
typeArguments: options.typeArguments,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
export interface DecreaseSupplyOptions {
|
|
93
|
-
package?: string;
|
|
94
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<string>];
|
|
95
|
-
typeArguments: [string];
|
|
96
|
-
}
|
|
97
|
-
export function decreaseSupply(options: DecreaseSupplyOptions) {
|
|
98
|
-
const packageAddress =
|
|
99
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
100
|
-
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
101
|
-
return (tx: Transaction) =>
|
|
102
|
-
tx.moveCall({
|
|
103
|
-
package: packageAddress,
|
|
104
|
-
module: 'balance',
|
|
105
|
-
function: 'decrease_supply',
|
|
106
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
107
|
-
typeArguments: options.typeArguments,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
export interface ZeroOptions {
|
|
111
|
-
package?: string;
|
|
112
|
-
arguments?: [];
|
|
113
|
-
typeArguments: [string];
|
|
114
|
-
}
|
|
115
|
-
export function zero(options: ZeroOptions) {
|
|
116
|
-
const packageAddress =
|
|
117
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
118
|
-
return (tx: Transaction) =>
|
|
119
|
-
tx.moveCall({
|
|
120
|
-
package: packageAddress,
|
|
121
|
-
module: 'balance',
|
|
122
|
-
function: 'zero',
|
|
123
|
-
typeArguments: options.typeArguments,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
export interface JoinOptions {
|
|
127
|
-
package?: string;
|
|
128
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<string>];
|
|
129
|
-
typeArguments: [string];
|
|
130
|
-
}
|
|
131
|
-
export function join(options: JoinOptions) {
|
|
132
|
-
const packageAddress =
|
|
133
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
134
|
-
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
135
|
-
return (tx: Transaction) =>
|
|
136
|
-
tx.moveCall({
|
|
137
|
-
package: packageAddress,
|
|
138
|
-
module: 'balance',
|
|
139
|
-
function: 'join',
|
|
140
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
141
|
-
typeArguments: options.typeArguments,
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
export interface SplitOptions {
|
|
145
|
-
package?: string;
|
|
146
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<number | bigint>];
|
|
147
|
-
typeArguments: [string];
|
|
148
|
-
}
|
|
149
|
-
export function split(options: SplitOptions) {
|
|
150
|
-
const packageAddress =
|
|
151
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
152
|
-
const argumentsTypes = [null, 'u64'] satisfies (string | null)[];
|
|
153
|
-
return (tx: Transaction) =>
|
|
154
|
-
tx.moveCall({
|
|
155
|
-
package: packageAddress,
|
|
156
|
-
module: 'balance',
|
|
157
|
-
function: 'split',
|
|
158
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
159
|
-
typeArguments: options.typeArguments,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
export interface WithdrawAllOptions {
|
|
163
|
-
package?: string;
|
|
164
|
-
arguments: [RawTransactionArgument<string>];
|
|
165
|
-
typeArguments: [string];
|
|
166
|
-
}
|
|
167
|
-
export function withdrawAll(options: WithdrawAllOptions) {
|
|
168
|
-
const packageAddress =
|
|
169
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
170
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
171
|
-
return (tx: Transaction) =>
|
|
172
|
-
tx.moveCall({
|
|
173
|
-
package: packageAddress,
|
|
174
|
-
module: 'balance',
|
|
175
|
-
function: 'withdraw_all',
|
|
176
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
177
|
-
typeArguments: options.typeArguments,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
export interface DestroyZeroOptions {
|
|
181
|
-
package?: string;
|
|
182
|
-
arguments: [RawTransactionArgument<string>];
|
|
183
|
-
typeArguments: [string];
|
|
184
|
-
}
|
|
185
|
-
export function destroyZero(options: DestroyZeroOptions) {
|
|
186
|
-
const packageAddress =
|
|
187
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
188
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
189
|
-
return (tx: Transaction) =>
|
|
190
|
-
tx.moveCall({
|
|
191
|
-
package: packageAddress,
|
|
192
|
-
module: 'balance',
|
|
193
|
-
function: 'destroy_zero',
|
|
194
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
195
|
-
typeArguments: options.typeArguments,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
export interface SendFundsOptions {
|
|
199
|
-
package?: string;
|
|
200
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<string>];
|
|
201
|
-
typeArguments: [string];
|
|
202
|
-
}
|
|
203
|
-
export function sendFunds(options: SendFundsOptions) {
|
|
204
|
-
const packageAddress =
|
|
205
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
206
|
-
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
207
|
-
return (tx: Transaction) =>
|
|
208
|
-
tx.moveCall({
|
|
209
|
-
package: packageAddress,
|
|
210
|
-
module: 'balance',
|
|
211
|
-
function: 'send_funds',
|
|
212
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
213
|
-
typeArguments: options.typeArguments,
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
export interface RedeemFundsOptions {
|
|
217
|
-
package?: string;
|
|
218
|
-
arguments: [RawTransactionArgument<string>];
|
|
219
|
-
typeArguments: [string];
|
|
220
|
-
}
|
|
221
|
-
export function redeemFunds(options: RedeemFundsOptions) {
|
|
222
|
-
const packageAddress =
|
|
223
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
224
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
225
|
-
return (tx: Transaction) =>
|
|
226
|
-
tx.moveCall({
|
|
227
|
-
package: packageAddress,
|
|
228
|
-
module: 'balance',
|
|
229
|
-
function: 'redeem_funds',
|
|
230
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
231
|
-
typeArguments: options.typeArguments,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
export interface WithdrawFundsFromObjectOptions {
|
|
235
|
-
package?: string;
|
|
236
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<number | bigint>];
|
|
237
|
-
typeArguments: [string];
|
|
238
|
-
}
|
|
239
|
-
export function withdrawFundsFromObject(options: WithdrawFundsFromObjectOptions) {
|
|
240
|
-
const packageAddress =
|
|
241
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
242
|
-
const argumentsTypes = ['0x2::object::ID', 'u64'] satisfies (string | null)[];
|
|
243
|
-
return (tx: Transaction) =>
|
|
244
|
-
tx.moveCall({
|
|
245
|
-
package: packageAddress,
|
|
246
|
-
module: 'balance',
|
|
247
|
-
function: 'withdraw_funds_from_object',
|
|
248
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
249
|
-
typeArguments: options.typeArguments,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
export interface SettledFundsValueOptions {
|
|
253
|
-
package?: string;
|
|
254
|
-
arguments: [RawTransactionArgument<string>, RawTransactionArgument<string>];
|
|
255
|
-
typeArguments: [string];
|
|
256
|
-
}
|
|
257
|
-
export function settledFundsValue(options: SettledFundsValueOptions) {
|
|
258
|
-
const packageAddress =
|
|
259
|
-
options.package ?? '0x0000000000000000000000000000000000000000000000000000000000000002';
|
|
260
|
-
const argumentsTypes = [null, 'address'] satisfies (string | null)[];
|
|
261
|
-
return (tx: Transaction) =>
|
|
262
|
-
tx.moveCall({
|
|
263
|
-
package: packageAddress,
|
|
264
|
-
module: 'balance',
|
|
265
|
-
function: 'settled_funds_value',
|
|
266
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
|
|
267
|
-
typeArguments: options.typeArguments,
|
|
268
|
-
});
|
|
269
|
-
}
|
|
@@ -24,7 +24,7 @@ export const KioskOwnerCap = new MoveStruct({
|
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
26
|
export const PurchaseCap = new MoveStruct({
|
|
27
|
-
name: `${$moduleName}::PurchaseCap
|
|
27
|
+
name: `${$moduleName}::PurchaseCap<phantom T0>`,
|
|
28
28
|
fields: {
|
|
29
29
|
id: bcs.Address,
|
|
30
30
|
kiosk_id: bcs.Address,
|
|
@@ -59,7 +59,7 @@ export const Lock = new MoveStruct({
|
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
export const ItemListed = new MoveStruct({
|
|
62
|
-
name: `${$moduleName}::ItemListed
|
|
62
|
+
name: `${$moduleName}::ItemListed<phantom T0>`,
|
|
63
63
|
fields: {
|
|
64
64
|
kiosk: bcs.Address,
|
|
65
65
|
id: bcs.Address,
|
|
@@ -67,7 +67,7 @@ export const ItemListed = new MoveStruct({
|
|
|
67
67
|
},
|
|
68
68
|
});
|
|
69
69
|
export const ItemPurchased = new MoveStruct({
|
|
70
|
-
name: `${$moduleName}::ItemPurchased
|
|
70
|
+
name: `${$moduleName}::ItemPurchased<phantom T0>`,
|
|
71
71
|
fields: {
|
|
72
72
|
kiosk: bcs.Address,
|
|
73
73
|
id: bcs.Address,
|
|
@@ -75,7 +75,7 @@ export const ItemPurchased = new MoveStruct({
|
|
|
75
75
|
},
|
|
76
76
|
});
|
|
77
77
|
export const ItemDelisted = new MoveStruct({
|
|
78
|
-
name: `${$moduleName}::ItemDelisted
|
|
78
|
+
name: `${$moduleName}::ItemDelisted<phantom T0>`,
|
|
79
79
|
fields: {
|
|
80
80
|
kiosk: bcs.Address,
|
|
81
81
|
id: bcs.Address,
|
|
@@ -9,7 +9,7 @@ import * as type_name from './deps/0x0000000000000000000000000000000000000000000
|
|
|
9
9
|
import * as balance from './balance.js';
|
|
10
10
|
const $moduleName = '0x2::transfer_policy';
|
|
11
11
|
export const TransferRequest = new MoveStruct({
|
|
12
|
-
name: `${$moduleName}::TransferRequest
|
|
12
|
+
name: `${$moduleName}::TransferRequest<phantom T0>`,
|
|
13
13
|
fields: {
|
|
14
14
|
item: bcs.Address,
|
|
15
15
|
paid: bcs.u64(),
|
|
@@ -18,7 +18,7 @@ export const TransferRequest = new MoveStruct({
|
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
export const TransferPolicy = new MoveStruct({
|
|
21
|
-
name: `${$moduleName}::TransferPolicy
|
|
21
|
+
name: `${$moduleName}::TransferPolicy<phantom T0>`,
|
|
22
22
|
fields: {
|
|
23
23
|
id: bcs.Address,
|
|
24
24
|
balance: balance.Balance,
|
|
@@ -26,26 +26,26 @@ export const TransferPolicy = new MoveStruct({
|
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
export const TransferPolicyCap = new MoveStruct({
|
|
29
|
-
name: `${$moduleName}::TransferPolicyCap
|
|
29
|
+
name: `${$moduleName}::TransferPolicyCap<phantom T0>`,
|
|
30
30
|
fields: {
|
|
31
31
|
id: bcs.Address,
|
|
32
32
|
policy_id: bcs.Address,
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
export const TransferPolicyCreated = new MoveStruct({
|
|
36
|
-
name: `${$moduleName}::TransferPolicyCreated
|
|
36
|
+
name: `${$moduleName}::TransferPolicyCreated<phantom T0>`,
|
|
37
37
|
fields: {
|
|
38
38
|
id: bcs.Address,
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
export const TransferPolicyDestroyed = new MoveStruct({
|
|
42
|
-
name: `${$moduleName}::TransferPolicyDestroyed
|
|
42
|
+
name: `${$moduleName}::TransferPolicyDestroyed<phantom T0>`,
|
|
43
43
|
fields: {
|
|
44
44
|
id: bcs.Address,
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
export const RuleKey = new MoveStruct({
|
|
48
|
-
name: `${$moduleName}::RuleKey
|
|
48
|
+
name: `${$moduleName}::RuleKey<phantom T0>`,
|
|
49
49
|
fields: {
|
|
50
50
|
dummy_field: bcs.bool(),
|
|
51
51
|
},
|