@mysten/kiosk
Advanced tools
Comparing version 0.0.0-experimental-20230719210218 to 0.0.0-experimental-20230720215128
@@ -156,4 +156,4 @@ "use strict"; | ||
} | ||
async function getKioskObject(provider, id) { | ||
const queryRes = await provider.getObject({ id, options: { showBcs: true } }); | ||
async function getKioskObject(client, id) { | ||
const queryRes = await client.getObject({ id, options: { showBcs: true } }); | ||
if (!queryRes || queryRes.error || !queryRes.data) { | ||
@@ -238,3 +238,3 @@ throw new Error(`Kiosk ${id} not found; ${queryRes.error}`); | ||
} | ||
async function getAllDynamicFields(provider, parentId, pagination) { | ||
async function getAllDynamicFields(client, parentId, pagination) { | ||
let hasNextPage = true; | ||
@@ -244,3 +244,3 @@ let cursor = void 0; | ||
while (hasNextPage) { | ||
const result = await provider.getDynamicFields({ | ||
const result = await client.getDynamicFields({ | ||
parentId, | ||
@@ -477,4 +477,4 @@ limit: pagination.limit || void 0, | ||
var import_sui3 = require("@mysten/sui.js"); | ||
async function fetchKiosk(provider, kioskId, pagination, options) { | ||
const data = await getAllDynamicFields(provider, kioskId, pagination); | ||
async function fetchKiosk(client, kioskId, pagination, options) { | ||
const data = await getAllDynamicFields(client, kioskId, pagination); | ||
const listings = []; | ||
@@ -484,4 +484,4 @@ const lockedItemIds = []; | ||
const [kiosk, listingObjects] = await Promise.all([ | ||
options.withKioskFields ? getKioskObject(provider, kioskId) : Promise.resolve(void 0), | ||
options.withListingPrices ? provider.multiGetObjects({ | ||
options.withKioskFields ? getKioskObject(client, kioskId) : Promise.resolve(void 0), | ||
options.withListingPrices ? client.multiGetObjects({ | ||
ids: kioskData.listingIds, | ||
@@ -503,3 +503,3 @@ options: { | ||
} | ||
async function getOwnedKiosks(provider, address, options) { | ||
async function getOwnedKiosks(client, address, options) { | ||
if (!(0, import_sui3.isValidSuiAddress)(address)) | ||
@@ -512,3 +512,3 @@ return { | ||
}; | ||
const { data, hasNextPage, nextCursor } = await provider.getOwnedObjects({ | ||
const { data, hasNextPage, nextCursor } = await client.getOwnedObjects({ | ||
owner: address, | ||
@@ -537,4 +537,4 @@ filter: { StructType: KIOSK_OWNER_CAP }, | ||
// src/query/transfer-policy.ts | ||
async function queryTransferPolicy(provider, type) { | ||
const { data } = await provider.queryEvents({ | ||
async function queryTransferPolicy(client, type) { | ||
const { data } = await client.queryEvents({ | ||
query: { | ||
@@ -545,3 +545,3 @@ MoveEventType: `${TRANSFER_POLICY_CREATED_EVENT}<${type}>` | ||
const search = data.map((event) => event.parsedJson); | ||
const policies = await provider.multiGetObjects({ | ||
const policies = await client.multiGetObjects({ | ||
ids: search.map((policy) => policy.id), | ||
@@ -548,0 +548,0 @@ options: { showBcs: true, showOwner: true } |
# @mysten/kiosk | ||
## 0.0.0-experimental-20230719210218 | ||
## 0.0.0-experimental-20230720215128 | ||
### Minor Changes | ||
- 6d41059c7: Update to use modular imports from @mysten/sui.js | ||
Some methods now accept a `SuiClient` imported from `@mysten/sui.js/client` rather than a `JsonRpcProvider` | ||
### Patch Changes | ||
@@ -13,4 +19,5 @@ | ||
- Updated dependencies [09f4ed3fc] | ||
- Updated dependencies [6d41059c7] | ||
- Updated dependencies [001148443] | ||
- @mysten/sui.js@0.0.0-experimental-20230719210218 | ||
- @mysten/sui.js@0.0.0-experimental-20230720215128 | ||
@@ -17,0 +24,0 @@ ## 0.3.3 |
@@ -156,4 +156,4 @@ "use strict"; | ||
} | ||
async function getKioskObject(provider, id) { | ||
const queryRes = await provider.getObject({ id, options: { showBcs: true } }); | ||
async function getKioskObject(client, id) { | ||
const queryRes = await client.getObject({ id, options: { showBcs: true } }); | ||
if (!queryRes || queryRes.error || !queryRes.data) { | ||
@@ -238,3 +238,3 @@ throw new Error(`Kiosk ${id} not found; ${queryRes.error}`); | ||
} | ||
async function getAllDynamicFields(provider, parentId, pagination) { | ||
async function getAllDynamicFields(client, parentId, pagination) { | ||
let hasNextPage = true; | ||
@@ -244,3 +244,3 @@ let cursor = void 0; | ||
while (hasNextPage) { | ||
const result = await provider.getDynamicFields({ | ||
const result = await client.getDynamicFields({ | ||
parentId, | ||
@@ -477,4 +477,4 @@ limit: pagination.limit || void 0, | ||
var import_sui3 = require("@mysten/sui.js"); | ||
async function fetchKiosk(provider, kioskId, pagination, options) { | ||
const data = await getAllDynamicFields(provider, kioskId, pagination); | ||
async function fetchKiosk(client, kioskId, pagination, options) { | ||
const data = await getAllDynamicFields(client, kioskId, pagination); | ||
const listings = []; | ||
@@ -484,4 +484,4 @@ const lockedItemIds = []; | ||
const [kiosk, listingObjects] = await Promise.all([ | ||
options.withKioskFields ? getKioskObject(provider, kioskId) : Promise.resolve(void 0), | ||
options.withListingPrices ? provider.multiGetObjects({ | ||
options.withKioskFields ? getKioskObject(client, kioskId) : Promise.resolve(void 0), | ||
options.withListingPrices ? client.multiGetObjects({ | ||
ids: kioskData.listingIds, | ||
@@ -503,3 +503,3 @@ options: { | ||
} | ||
async function getOwnedKiosks(provider, address, options) { | ||
async function getOwnedKiosks(client, address, options) { | ||
if (!(0, import_sui3.isValidSuiAddress)(address)) | ||
@@ -512,3 +512,3 @@ return { | ||
}; | ||
const { data, hasNextPage, nextCursor } = await provider.getOwnedObjects({ | ||
const { data, hasNextPage, nextCursor } = await client.getOwnedObjects({ | ||
owner: address, | ||
@@ -537,4 +537,4 @@ filter: { StructType: KIOSK_OWNER_CAP }, | ||
// src/query/transfer-policy.ts | ||
async function queryTransferPolicy(provider, type) { | ||
const { data } = await provider.queryEvents({ | ||
async function queryTransferPolicy(client, type) { | ||
const { data } = await client.queryEvents({ | ||
query: { | ||
@@ -545,3 +545,3 @@ MoveEventType: `${TRANSFER_POLICY_CREATED_EVENT}<${type}>` | ||
const search = data.map((event) => event.parsedJson); | ||
const policies = await provider.multiGetObjects({ | ||
const policies = await client.multiGetObjects({ | ||
ids: search.map((policy) => policy.id), | ||
@@ -548,0 +548,0 @@ options: { showBcs: true, showOwner: true } |
@@ -1,4 +0,5 @@ | ||
import { JsonRpcProvider, PaginationArguments, SuiAddress } from '@mysten/sui.js'; | ||
import { 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>; | ||
import { SuiClient, PaginationArguments } from '@mysten/sui.js/client'; | ||
export declare function fetchKiosk(client: SuiClient, kioskId: SuiAddress, pagination: PaginationArguments<string>, options: FetchKioskOptions): Promise<PagedKioskData>; | ||
/** | ||
@@ -10,4 +11,4 @@ * A function to fetch all the user's kiosk Caps | ||
*/ | ||
export declare function getOwnedKiosks(provider: JsonRpcProvider, address: SuiAddress, options?: { | ||
export declare function getOwnedKiosks(client: SuiClient, address: SuiAddress, options?: { | ||
pagination?: PaginationArguments<string>; | ||
}): Promise<OwnedKiosks>; |
@@ -1,2 +0,2 @@ | ||
import { JsonRpcProvider } from '@mysten/sui.js'; | ||
import { SuiClient } from '@mysten/sui.js/client'; | ||
import { TransferPolicy } from '../types'; | ||
@@ -12,2 +12,2 @@ /** | ||
*/ | ||
export declare function queryTransferPolicy(provider: JsonRpcProvider, type: string): Promise<TransferPolicy[]>; | ||
export declare function queryTransferPolicy(client: SuiClient, type: string): Promise<TransferPolicy[]>; |
@@ -1,2 +0,3 @@ | ||
import { TransactionArgument, TransactionBlock } from '@mysten/sui.js'; | ||
import { TransactionArgument } from '@mysten/sui.js'; | ||
import { TransactionBlock } from '@mysten/sui.js/transactions'; | ||
import { ObjectArgument, RulesEnvironmentParam } from '../types'; | ||
@@ -3,0 +4,0 @@ /** |
import { SuiAddress } from '@mysten/sui.js'; | ||
export type Environment = 'mainnet' | 'testnet' | 'devnet' | 'custom'; | ||
/** A Parameter to support enivronments for rules. */ | ||
/** A Parameter to support environments for rules. */ | ||
export type RulesEnvironmentParam = { | ||
@@ -5,0 +5,0 @@ env: Environment; |
@@ -1,4 +0,5 @@ | ||
import { JsonRpcProvider, ObjectId, PaginationArguments, SharedObjectRef, SuiObjectRef, SuiObjectResponse, TransactionArgument, TransactionBlock } from '@mysten/sui.js'; | ||
import { ObjectId, SharedObjectRef, SuiObjectRef, SuiObjectResponse, TransactionArgument, TransactionBlock } from '@mysten/sui.js'; | ||
import { type DynamicFieldInfo } from '@mysten/sui.js'; | ||
import { Kiosk, KioskData, KioskListing, RulesEnvironmentParam } from './types'; | ||
import { SuiClient, PaginationArguments } from '@mysten/sui.js/client'; | ||
export declare const rulesPackageAddresses: { | ||
@@ -18,3 +19,3 @@ mainnet: string; | ||
export declare function objArg(tx: TransactionBlock, arg: string | SharedObjectRef | SuiObjectRef | TransactionArgument): TransactionArgument; | ||
export declare function getKioskObject(provider: JsonRpcProvider, id: string): Promise<Kiosk>; | ||
export declare function getKioskObject(client: SuiClient, id: string): Promise<Kiosk>; | ||
export declare function extractKioskData(data: DynamicFieldInfo[], listings: KioskListing[], lockedItemIds: string[]): KioskData; | ||
@@ -39,3 +40,3 @@ export declare function getTypeWithoutPackageAddress(type: string): string; | ||
*/ | ||
export declare function getAllDynamicFields(provider: JsonRpcProvider, parentId: ObjectId, pagination: PaginationArguments<string>): Promise<{ | ||
export declare function getAllDynamicFields(client: SuiClient, parentId: ObjectId, pagination: PaginationArguments<string>): Promise<{ | ||
type: "DynamicField" | "DynamicObject"; | ||
@@ -42,0 +43,0 @@ objectType: string; |
@@ -5,3 +5,3 @@ { | ||
"description": "Sui Kiosk library", | ||
"version": "0.0.0-experimental-20230719210218", | ||
"version": "0.0.0-experimental-20230720215128", | ||
"license": "Apache-2.0", | ||
@@ -28,3 +28,3 @@ "main": "./dist/index.js", | ||
"dependencies": { | ||
"@mysten/sui.js": "0.0.0-experimental-20230719210218" | ||
"@mysten/sui.js": "0.0.0-experimental-20230720215128" | ||
}, | ||
@@ -31,0 +31,0 @@ "devDependencies": { |
@@ -27,6 +27,6 @@ # Kiosk SDK | ||
import { fetchKiosk } from '@mysten/kiosk'; | ||
import { Connection, JsonRpcProvider } from '@mysten/sui.js'; | ||
import { SuiClient } from '@mysten/sui.js/client'; | ||
const provider = new JsonRpcProvider( | ||
new Connection({ fullnode: 'https://fullnode.testnet.sui.io:443' }), | ||
const client = new SuiClient( | ||
url: 'https://fullnode.testnet.sui.io:443', | ||
); | ||
@@ -38,3 +38,3 @@ | ||
const { data } = await fetchKiosk( | ||
provider, | ||
client, | ||
kioskAddress, | ||
@@ -56,6 +56,6 @@ {}, // empty pagination, currently disabled. | ||
import { queryTransferPolicy, purchaseAndResolvePolicies, place, testnetEnvironment } from '@mysten/kiosk'; | ||
import { Connection, JsonRpcProvider } from '@mysten/sui.js'; | ||
import { SuiClient } from '@mysten/sui.js/client'; | ||
const provider = new JsonRpcProvider( | ||
new Connection({ fullnode: 'https://fullnode.testnet.sui.io:443' }), | ||
const client = new SuiClient( | ||
url: 'https://fullnode.testnet.sui.io:443', | ||
); | ||
@@ -82,3 +82,3 @@ | ||
// fetch the policy of the item (could be an array, if there's more than one transfer policy) | ||
const policies = await queryTransferPolicy(provider, item.type); | ||
const policies = await queryTransferPolicy(client, item.type); | ||
// selecting the first one for simplicity. | ||
@@ -85,0 +85,0 @@ const policyId = policy[0]?.id; |
@@ -5,5 +5,3 @@ // Copyright (c) Mysten Labs, Inc. | ||
import { | ||
JsonRpcProvider, | ||
ObjectId, | ||
PaginationArguments, | ||
SuiAddress, | ||
@@ -29,5 +27,6 @@ SuiObjectData, | ||
} from '../types'; | ||
import { SuiClient, PaginationArguments } from '@mysten/sui.js/client'; | ||
export async function fetchKiosk( | ||
provider: JsonRpcProvider, | ||
client: SuiClient, | ||
kioskId: SuiAddress, | ||
@@ -41,3 +40,3 @@ pagination: PaginationArguments<string>, | ||
// This can't work with pagination currently. | ||
const data = await getAllDynamicFields(provider, kioskId, pagination); | ||
const data = await getAllDynamicFields(client, kioskId, pagination); | ||
@@ -54,5 +53,5 @@ const listings: KioskListing[] = []; | ||
const [kiosk, listingObjects] = await Promise.all([ | ||
options.withKioskFields ? getKioskObject(provider, kioskId) : Promise.resolve(undefined), | ||
options.withKioskFields ? getKioskObject(client, kioskId) : Promise.resolve(undefined), | ||
options.withListingPrices | ||
? provider.multiGetObjects({ | ||
? client.multiGetObjects({ | ||
ids: kioskData.listingIds, | ||
@@ -86,3 +85,3 @@ options: { | ||
export async function getOwnedKiosks( | ||
provider: JsonRpcProvider, | ||
client: SuiClient, | ||
address: SuiAddress, | ||
@@ -102,3 +101,3 @@ options?: { | ||
// fetch owned kiosk caps, paginated. | ||
const { data, hasNextPage, nextCursor } = await provider.getOwnedObjects({ | ||
const { data, hasNextPage, nextCursor } = await client.getOwnedObjects({ | ||
owner: address, | ||
@@ -105,0 +104,0 @@ filter: { StructType: KIOSK_OWNER_CAP }, |
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { JsonRpcProvider } from '@mysten/sui.js'; | ||
import { SuiClient } from '@mysten/sui.js/client'; | ||
import { bcs } from '../bcs'; | ||
@@ -18,7 +18,7 @@ import { TRANSFER_POLICY_CREATED_EVENT, TRANSFER_POLICY_TYPE, TransferPolicy } from '../types'; | ||
export async function queryTransferPolicy( | ||
provider: JsonRpcProvider, | ||
client: SuiClient, | ||
type: string, | ||
): Promise<TransferPolicy[]> { | ||
// console.log('event type: %s', `${TRANSFER_POLICY_CREATED_EVENT}<${type}>`); | ||
const { data } = await provider.queryEvents({ | ||
const { data } = await client.queryEvents({ | ||
query: { | ||
@@ -30,3 +30,3 @@ MoveEventType: `${TRANSFER_POLICY_CREATED_EVENT}<${type}>`, | ||
const search = data.map((event) => event.parsedJson as { id: string }); | ||
const policies = await provider.multiGetObjects({ | ||
const policies = await client.multiGetObjects({ | ||
ids: search.map((policy) => policy.id), | ||
@@ -33,0 +33,0 @@ options: { showBcs: true, showOwner: true }, |
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { TransactionArgument, TransactionBlock } from '@mysten/sui.js'; | ||
import { TransactionArgument } from '@mysten/sui.js'; | ||
import { TransactionBlock } from '@mysten/sui.js/transactions'; | ||
import { getRulePackageAddress, objArg } from '../utils'; | ||
@@ -6,0 +7,0 @@ import { lock } from './kiosk'; |
@@ -9,3 +9,3 @@ // Copyright (c) Mysten Labs, Inc. | ||
/** A Parameter to support enivronments for rules. */ | ||
/** A Parameter to support environments for rules. */ | ||
export type RulesEnvironmentParam = { env: Environment; address?: SuiAddress }; | ||
@@ -12,0 +12,0 @@ |
@@ -5,5 +5,3 @@ // Copyright (c) Mysten Labs, Inc. | ||
import { | ||
JsonRpcProvider, | ||
ObjectId, | ||
PaginationArguments, | ||
SharedObjectRef, | ||
@@ -20,2 +18,3 @@ SuiObjectRef, | ||
import { MAINNET_RULES_PACKAGE_ADDRESS, TESTNET_RULES_PACKAGE_ADDRESS } from './constants'; | ||
import { SuiClient, PaginationArguments } from '@mysten/sui.js/client'; | ||
@@ -61,4 +60,4 @@ /* A simple map to the rule package addresses */ | ||
export async function getKioskObject(provider: JsonRpcProvider, id: string): Promise<Kiosk> { | ||
const queryRes = await provider.getObject({ id, options: { showBcs: true } }); | ||
export async function getKioskObject(client: SuiClient, id: string): Promise<Kiosk> { | ||
const queryRes = await client.getObject({ id, options: { showBcs: true } }); | ||
@@ -188,3 +187,3 @@ if (!queryRes || queryRes.error || !queryRes.data) { | ||
export async function getAllDynamicFields( | ||
provider: JsonRpcProvider, | ||
client: SuiClient, | ||
parentId: ObjectId, | ||
@@ -198,3 +197,3 @@ pagination: PaginationArguments<string>, | ||
while (hasNextPage) { | ||
const result = await provider.getDynamicFields({ | ||
const result = await client.getDynamicFields({ | ||
parentId, | ||
@@ -201,0 +200,0 @@ limit: pagination.limit || undefined, |
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
213514
3118
+ Added@mysten/sui.js@0.0.0-experimental-20230720215128(transitive)
- Removed@mysten/sui.js@0.0.0-experimental-20230719210218(transitive)