New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mysten/kiosk

Package Overview
Dependencies
Maintainers
4
Versions
362
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mysten/kiosk - npm Package Compare versions

Comparing version 0.0.0-experimental-20230610220159 to 0.0.0-experimental-20230612192627

35

./dist/index.js

@@ -53,2 +53,3 @@ "use strict";

getKioskObject: () => getKioskObject,
getOwnedKiosks: () => getOwnedKiosks,
getRulePackageAddress: () => getRulePackageAddress,

@@ -520,2 +521,3 @@ getTypeWithoutPackageAddress: () => getTypeWithoutPackageAddress,

// src/query/kiosk.ts
var import_sui3 = require("@mysten/sui.js");
async function fetchKiosk(provider, kioskId, pagination, options) {

@@ -545,2 +547,34 @@ const data = await getAllDynamicFields(provider, kioskId, pagination);

}
async function getOwnedKiosks(provider, address, options) {
if (!(0, import_sui3.isValidSuiAddress)(address))
return {
nextCursor: null,
hasNextPage: false,
kioskOwnerCaps: [],
kioskIds: []
};
const { data, hasNextPage, nextCursor } = await provider.getOwnedObjects({
owner: address,
filter: { StructType: KIOSK_OWNER_CAP },
options: {
showContent: true
},
...options?.pagination || {}
});
const kioskIdList = data?.map(
(x) => (0, import_sui3.getObjectFields)(x)?.for
);
const filteredData = data.filter((x) => "data" in x).map((x) => x.data);
return {
nextCursor,
hasNextPage,
kioskOwnerCaps: filteredData.map((x, idx) => ({
digest: x.digest,
version: x.version,
objectId: x.objectId,
kioskId: kioskIdList[idx]
})),
kioskIds: kioskIdList
};
}

@@ -607,2 +641,3 @@ // src/query/transfer-policy.ts

getKioskObject,
getOwnedKiosks,
getRulePackageAddress,

@@ -609,0 +644,0 @@ getTypeWithoutPackageAddress,

5

CHANGELOG.md
# @mysten/kiosk
## 0.0.0-experimental-20230610220159
## 0.0.0-experimental-20230612192627
### Patch Changes
- 6a2a42d779: Add `getOwnedKiosks` query to easily get owned kiosks and their ownerCaps for an address
- abf6ad381e: Refactor the fetchKiosk function to return all content instead of paginating, to prevent missing data
- d72fdb5a5c: Fix on createTransferPolicy method. Updated type arguments for public_share_object command.
- @mysten/sui.js@0.0.0-experimental-20230610220159
- @mysten/sui.js@0.0.0-experimental-20230612192627

@@ -11,0 +12,0 @@ ## 0.3.0

@@ -53,2 +53,3 @@ "use strict";

getKioskObject: () => getKioskObject,
getOwnedKiosks: () => getOwnedKiosks,
getRulePackageAddress: () => getRulePackageAddress,

@@ -520,2 +521,3 @@ getTypeWithoutPackageAddress: () => getTypeWithoutPackageAddress,

// src/query/kiosk.ts
var import_sui3 = require("@mysten/sui.js");
async function fetchKiosk(provider, kioskId, pagination, options) {

@@ -545,2 +547,34 @@ const data = await getAllDynamicFields(provider, kioskId, pagination);

}
async function getOwnedKiosks(provider, address, options) {
if (!(0, import_sui3.isValidSuiAddress)(address))
return {
nextCursor: null,
hasNextPage: false,
kioskOwnerCaps: [],
kioskIds: []
};
const { data, hasNextPage, nextCursor } = await provider.getOwnedObjects({
owner: address,
filter: { StructType: KIOSK_OWNER_CAP },
options: {
showContent: true
},
...options?.pagination || {}
});
const kioskIdList = data?.map(
(x) => (0, import_sui3.getObjectFields)(x)?.for
);
const filteredData = data.filter((x) => "data" in x).map((x) => x.data);
return {
nextCursor,
hasNextPage,
kioskOwnerCaps: filteredData.map((x, idx) => ({
digest: x.digest,
version: x.version,
objectId: x.objectId,
kioskId: kioskIdList[idx]
})),
kioskIds: kioskIdList
};
}

@@ -607,2 +641,3 @@ // src/query/transfer-policy.ts

getKioskObject,
getOwnedKiosks,
getRulePackageAddress,

@@ -609,0 +644,0 @@ getTypeWithoutPackageAddress,

62

dist/query/kiosk.d.ts

@@ -1,54 +0,12 @@

import { JsonRpcProvider, ObjectId, ObjectType, PaginationArguments, SuiAddress } from '@mysten/sui.js';
import { Kiosk } from '../types';
import { JsonRpcProvider, PaginationArguments, SuiAddress } from '@mysten/sui.js';
import { FetchKioskOptions, OwnedKiosks, PagedKioskData } from '../types';
export declare function fetchKiosk(provider: JsonRpcProvider, kioskId: SuiAddress, pagination: PaginationArguments<string>, options: FetchKioskOptions): Promise<PagedKioskData>;
/**
* A dynamic field `Listing { ID, isExclusive }` attached to the Kiosk.
* Holds a `u64` value - the price of the item.
* A function to fetch all the user's kiosk Caps
* And a list of the kiosk address ids.
* Returns a list of `kioskOwnerCapIds` and `kioskIds`.
* Extra options allow pagination.
*/
export type KioskListing = {
/** The ID of the Item */
objectId: ObjectId;
/**
* Whether or not there's a `PurchaseCap` issued. `true` means that
* the listing is controlled by some logic and can't be purchased directly.
*
* TODO: consider renaming the field for better indication.
*/
isExclusive: boolean;
/** The ID of the listing */
listingId: ObjectId;
price?: string;
};
/**
* A dynamic field `Item { ID }` attached to the Kiosk.
* Holds an Item `T`. The type of the item is known upfront.
*/
export type KioskItem = {
/** The ID of the Item */
objectId: ObjectId;
/** The type of the Item */
type: ObjectType;
/** Whether the item is Locked (there must be a `Lock` Dynamic Field) */
isLocked: boolean;
/** Optional listing */
listing?: KioskListing;
};
/**
* Aggregated data from the Kiosk.
*/
export type KioskData = {
items: KioskItem[];
itemIds: ObjectId[];
listingIds: ObjectId[];
kiosk?: Kiosk;
extensions: any[];
};
export type PagedKioskData = {
data: KioskData;
nextCursor: string | null;
hasNextPage: boolean;
};
export type FetchKioskOptions = {
withKioskFields?: boolean;
withListingPrices?: boolean;
};
export declare function fetchKiosk(provider: JsonRpcProvider, kioskId: SuiAddress, pagination: PaginationArguments<string>, options: FetchKioskOptions): Promise<PagedKioskData>;
export declare function getOwnedKiosks(provider: JsonRpcProvider, address: SuiAddress, options?: {
pagination?: PaginationArguments<string>;
}): Promise<OwnedKiosks>;

@@ -1,2 +0,2 @@

import { TransactionArgument } from '@mysten/sui.js';
import { ObjectDigest, ObjectId, ObjectType, PaginatedObjectsResponse, TransactionArgument } from '@mysten/sui.js';
import { ObjectArgument } from '.';

@@ -53,1 +53,62 @@ /** The Kiosk module. */

};
/**
* A dynamic field `Listing { ID, isExclusive }` attached to the Kiosk.
* Holds a `u64` value - the price of the item.
*/
export type KioskListing = {
/** The ID of the Item */
objectId: ObjectId;
/**
* Whether or not there's a `PurchaseCap` issued. `true` means that
* the listing is controlled by some logic and can't be purchased directly.
*
* TODO: consider renaming the field for better indication.
*/
isExclusive: boolean;
/** The ID of the listing */
listingId: ObjectId;
price?: string;
};
/**
* A dynamic field `Item { ID }` attached to the Kiosk.
* Holds an Item `T`. The type of the item is known upfront.
*/
export type KioskItem = {
/** The ID of the Item */
objectId: ObjectId;
/** The type of the Item */
type: ObjectType;
/** Whether the item is Locked (there must be a `Lock` Dynamic Field) */
isLocked: boolean;
/** Optional listing */
listing?: KioskListing;
};
/**
* Aggregated data from the Kiosk.
*/
export type KioskData = {
items: KioskItem[];
itemIds: ObjectId[];
listingIds: ObjectId[];
kiosk?: Kiosk;
extensions: any[];
};
export type PagedKioskData = {
data: KioskData;
nextCursor: string | null;
hasNextPage: boolean;
};
export type FetchKioskOptions = {
withKioskFields?: boolean;
withListingPrices?: boolean;
};
export type OwnedKiosks = {
kioskOwnerCaps: KioskOwnerCap[];
kioskIds: ObjectId[];
} & Omit<PaginatedObjectsResponse, 'data'>;
export type KioskOwnerCap = {
objectId: ObjectId;
kioskId: ObjectId;
digest: ObjectDigest;
version: string;
};
import { JsonRpcProvider, ObjectId, PaginationArguments, SharedObjectRef, SuiObjectRef, SuiObjectResponse, TransactionArgument, TransactionBlock } from '@mysten/sui.js';
import { KioskData, KioskListing } from './query/kiosk';
import { DynamicFieldInfo } from '@mysten/sui.js/dist/types/dynamic_fields';
import { Kiosk, RulesEnvironmentParam } from './types';
import { Kiosk, KioskData, KioskListing, RulesEnvironmentParam } from './types';
export declare const rulesPackageAddresses: {

@@ -6,0 +5,0 @@ mainnet: string;

@@ -5,3 +5,3 @@ {

"description": "Sui Kiosk library",
"version": "0.0.0-experimental-20230610220159",
"version": "0.0.0-experimental-20230612192627",
"license": "Apache-2.0",

@@ -28,3 +28,3 @@ "main": "./dist/index.js",

"dependencies": {
"@mysten/sui.js": "0.0.0-experimental-20230610220159"
"@mysten/sui.js": "0.0.0-experimental-20230612192627"
},

@@ -31,0 +31,0 @@ "devDependencies": {

@@ -7,5 +7,8 @@ // Copyright (c) Mysten Labs, Inc.

ObjectId,
ObjectType,
PaginationArguments,
SuiAddress,
SuiObjectData,
SuiObjectResponse,
getObjectFields,
isValidSuiAddress,
} from '@mysten/sui.js';

@@ -19,59 +22,10 @@ import {

} from '../utils';
import { Kiosk } from '../types';
import {
FetchKioskOptions,
KIOSK_OWNER_CAP,
KioskListing,
OwnedKiosks,
PagedKioskData,
} from '../types';
/**
* A dynamic field `Listing { ID, isExclusive }` attached to the Kiosk.
* Holds a `u64` value - the price of the item.
*/
export type KioskListing = {
/** The ID of the Item */
objectId: ObjectId;
/**
* Whether or not there's a `PurchaseCap` issued. `true` means that
* the listing is controlled by some logic and can't be purchased directly.
*
* TODO: consider renaming the field for better indication.
*/
isExclusive: boolean;
/** The ID of the listing */
listingId: ObjectId;
price?: string;
};
/**
* A dynamic field `Item { ID }` attached to the Kiosk.
* Holds an Item `T`. The type of the item is known upfront.
*/
export type KioskItem = {
/** The ID of the Item */
objectId: ObjectId;
/** The type of the Item */
type: ObjectType;
/** Whether the item is Locked (there must be a `Lock` Dynamic Field) */
isLocked: boolean;
/** Optional listing */
listing?: KioskListing;
};
/**
* Aggregated data from the Kiosk.
*/
export type KioskData = {
items: KioskItem[];
itemIds: ObjectId[];
listingIds: ObjectId[];
kiosk?: Kiosk;
extensions: any[]; // type will be defined on later versions of the SDK.
};
export type PagedKioskData = {
data: KioskData;
nextCursor: string | null;
hasNextPage: boolean;
};
export type FetchKioskOptions = {
withKioskFields?: boolean;
withListingPrices?: boolean;
};
export async function fetchKiosk(

@@ -124,1 +78,56 @@ provider: JsonRpcProvider,

}
/**
* A function to fetch all the user's kiosk Caps
* And a list of the kiosk address ids.
* Returns a list of `kioskOwnerCapIds` and `kioskIds`.
* Extra options allow pagination.
*/
export async function getOwnedKiosks(
provider: JsonRpcProvider,
address: SuiAddress,
options?: {
pagination?: PaginationArguments<string>;
},
): Promise<OwnedKiosks> {
if (!isValidSuiAddress(address))
return {
nextCursor: null,
hasNextPage: false,
kioskOwnerCaps: [],
kioskIds: [],
};
// fetch owned kiosk caps, paginated.
const { data, hasNextPage, nextCursor } = await provider.getOwnedObjects({
owner: address,
filter: { StructType: KIOSK_OWNER_CAP },
options: {
showContent: true,
},
...(options?.pagination || {}),
});
// get kioskIds from the OwnerCaps.
const kioskIdList = data?.map(
(x: SuiObjectResponse) => getObjectFields(x)?.for,
);
// clean up data that might have an error in them.
// only return valid objects.
const filteredData = data
.filter((x) => 'data' in x)
.map((x) => x.data) as SuiObjectData[];
return {
nextCursor,
hasNextPage,
kioskOwnerCaps: filteredData.map((x, idx) => ({
digest: x.digest,
version: x.version,
objectId: x.objectId,
kioskId: kioskIdList[idx],
})),
kioskIds: kioskIdList,
};
}
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { TransactionArgument } from '@mysten/sui.js';
import {
ObjectDigest,
ObjectId,
ObjectType,
PaginatedObjectsResponse,
TransactionArgument,
} from '@mysten/sui.js';
import { ObjectArgument } from '.';

@@ -67,1 +73,68 @@

};
/**
* A dynamic field `Listing { ID, isExclusive }` attached to the Kiosk.
* Holds a `u64` value - the price of the item.
*/
export type KioskListing = {
/** The ID of the Item */
objectId: ObjectId;
/**
* Whether or not there's a `PurchaseCap` issued. `true` means that
* the listing is controlled by some logic and can't be purchased directly.
*
* TODO: consider renaming the field for better indication.
*/
isExclusive: boolean;
/** The ID of the listing */
listingId: ObjectId;
price?: string;
};
/**
* A dynamic field `Item { ID }` attached to the Kiosk.
* Holds an Item `T`. The type of the item is known upfront.
*/
export type KioskItem = {
/** The ID of the Item */
objectId: ObjectId;
/** The type of the Item */
type: ObjectType;
/** Whether the item is Locked (there must be a `Lock` Dynamic Field) */
isLocked: boolean;
/** Optional listing */
listing?: KioskListing;
};
/**
* Aggregated data from the Kiosk.
*/
export type KioskData = {
items: KioskItem[];
itemIds: ObjectId[];
listingIds: ObjectId[];
kiosk?: Kiosk;
extensions: any[]; // type will be defined on later versions of the SDK.
};
export type PagedKioskData = {
data: KioskData;
nextCursor: string | null;
hasNextPage: boolean;
};
export type FetchKioskOptions = {
withKioskFields?: boolean;
withListingPrices?: boolean;
};
export type OwnedKiosks = {
kioskOwnerCaps: KioskOwnerCap[];
kioskIds: ObjectId[];
} & Omit<PaginatedObjectsResponse, 'data'>;
export type KioskOwnerCap = {
objectId: ObjectId;
kioskId: ObjectId;
digest: ObjectDigest;
version: string;
};

@@ -15,7 +15,12 @@ // Copyright (c) Mysten Labs, Inc.

} from '@mysten/sui.js';
import { KioskData, KioskListing } from './query/kiosk';
import { DynamicFieldInfo } from '@mysten/sui.js/dist/types/dynamic_fields';
import { bcs } from './bcs';
import { KIOSK_TYPE, Kiosk, RulesEnvironmentParam } from './types';
import {
KIOSK_TYPE,
Kiosk,
KioskData,
KioskListing,
RulesEnvironmentParam,
} from './types';
import {
MAINNET_RULES_PACKAGE_ADDRESS,

@@ -22,0 +27,0 @@ TESTNET_RULES_PACKAGE_ADDRESS,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc