diff --git a/examples/example-vite-react-app-recs/src/dojo/setup.ts b/examples/example-vite-react-app-recs/src/dojo/setup.ts index 26c6a405..299834b7 100644 --- a/examples/example-vite-react-app-recs/src/dojo/setup.ts +++ b/examples/example-vite-react-app-recs/src/dojo/setup.ts @@ -29,6 +29,8 @@ export async function setup({ ...config }: DojoConfig) { contractComponents as any, undefined, [], + [], + [], 3000, true ); @@ -36,7 +38,8 @@ export async function setup({ ...config }: DojoConfig) { // Create client-side components that mirror the contract components const clientComponents = createClientComponents({ contractComponents }); - // Initialize the Dojo provider with the manifest and RPC URL + // Initialize the Dojo provider with t + // he manifest and RPC URL const dojoProvider = new DojoProvider(config.manifest, config.rpcUrl); // Set up event synchronization between the client and the Dojo network @@ -44,6 +47,8 @@ export async function setup({ ...config }: DojoConfig) { toriiClient, contractComponents as any, undefined, + [], + [], [] ); @@ -80,16 +85,8 @@ export async function setup({ ...config }: DojoConfig) { clientComponents, contractComponents, systemCalls: createSystemCalls({ client }, clientComponents, world), - publish: ( - typedData: string, - signature: ArraySignatureType, - isSessionSignature = false - ) => { - toriiClient.publishMessage( - typedData, - signature, - isSessionSignature - ); + publish: (typedData: string, signature: ArraySignatureType) => { + toriiClient.publishMessage(typedData, signature); }, config, dojoProvider, diff --git a/examples/example-vite-react-phaser-recs/src/dojo/generated/setup.ts b/examples/example-vite-react-phaser-recs/src/dojo/generated/setup.ts index d5afddb8..207d6a97 100644 --- a/examples/example-vite-react-phaser-recs/src/dojo/generated/setup.ts +++ b/examples/example-vite-react-phaser-recs/src/dojo/generated/setup.ts @@ -46,16 +46,8 @@ export async function setup({ ...config }: DojoConfig) { contractComponents, clientComponents ), - publish: ( - typedData: string, - signature: ArraySignatureType, - isSessionSignature = false - ) => { - toriiClient.publishMessage( - typedData, - signature, - isSessionSignature - ); + publish: (typedData: string, signature: ArraySignatureType) => { + toriiClient.publishMessage(typedData, signature); }, config, sync, diff --git a/examples/example-vite-react-phaser-recs/tailwind.config.js b/examples/example-vite-react-phaser-recs/tailwind.config.js index 6d3e2407..5cdc1b96 100644 --- a/examples/example-vite-react-phaser-recs/tailwind.config.js +++ b/examples/example-vite-react-phaser-recs/tailwind.config.js @@ -1,5 +1,5 @@ /** @type {import('tailwindcss').Config} */ -module.exports = { +export default { darkMode: ["class"], content: [ "./pages/**/*.{ts,tsx}", @@ -72,5 +72,5 @@ module.exports = { }, }, }, - plugins: [require("tailwindcss-animate")], + plugins: [import("tailwindcss-animate")], }; diff --git a/examples/example-vite-react-pwa-recs/src/dojo/generated/setup.ts b/examples/example-vite-react-pwa-recs/src/dojo/generated/setup.ts index c10d270c..dacff0ff 100644 --- a/examples/example-vite-react-pwa-recs/src/dojo/generated/setup.ts +++ b/examples/example-vite-react-pwa-recs/src/dojo/generated/setup.ts @@ -73,16 +73,8 @@ export async function setup({ ...config }: DojoConfig) { contractComponents, clientComponents ), - publish: ( - typedData: string, - signature: ArraySignatureType, - isSessionSignature = false - ) => { - toriiClient.publishMessage( - typedData, - signature, - isSessionSignature - ); + publish: (typedData: string, signature: ArraySignatureType) => { + toriiClient.publishMessage(typedData, signature); }, config, dojoProvider, diff --git a/examples/example-vite-react-threejs-recs/src/dojo/generated/setup.ts b/examples/example-vite-react-threejs-recs/src/dojo/generated/setup.ts index 66604a46..bcd64209 100644 --- a/examples/example-vite-react-threejs-recs/src/dojo/generated/setup.ts +++ b/examples/example-vite-react-threejs-recs/src/dojo/generated/setup.ts @@ -73,16 +73,8 @@ export async function setup({ ...config }: DojoConfig) { contractComponents, clientComponents ), - publish: ( - typedData: string, - signature: ArraySignatureType, - isSessionSignature: boolean = false - ) => { - toriiClient.publishMessage( - typedData, - signature, - isSessionSignature - ); + publish: (typedData: string, signature: ArraySignatureType) => { + toriiClient.publishMessage(typedData, signature); }, config, world, diff --git a/examples/example-vite-react-threejs-recs/tailwind.config.js b/examples/example-vite-react-threejs-recs/tailwind.config.js index 0976199d..0439a9d4 100644 --- a/examples/example-vite-react-threejs-recs/tailwind.config.js +++ b/examples/example-vite-react-threejs-recs/tailwind.config.js @@ -1,5 +1,5 @@ /** @type {import('tailwindcss').Config} */ -module.exports = { +export default { darkMode: ["class"], content: [ "./pages/**/*.{ts,tsx}", @@ -73,5 +73,5 @@ module.exports = { }, }, }, - plugins: [require("tailwindcss-animate")], + plugins: [import("tailwindcss-animate")], }; diff --git a/package.json b/package.json index 1b2f183d..5e8f533c 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,25 @@ { - "name": "dojo.js", - "scripts": { - "build": "bash ./scripts/build-packages.sh", - "build-examples": "bash ./scripts/build-examples.sh", - "clean": "bash ./scripts/clean.sh", - "prettier-check": "npx prettier --check .", - "prettier": "npx prettier --write .", - "release": "pnpm build && pnpm prettier && npx lerna publish --no-private --force-publish", - "docs": "npx typedoc --out docs", - "prepare": "husky install" - }, - "devDependencies": { - "husky": "^9.1.6", - "lerna": "^8.1.5", - "prettier": "^3.3.3", - "tsup": "^8.1.0", - "typedoc": "^0.26.7", - "@typhonjs-typedoc/typedoc-theme-dmt": "^0.2.1", - "typedoc-plugin-coverage": "^3.3.0", - "@commitlint/cli": "^18.4.4", - "@commitlint/config-conventional": "^18.4.4", - "@ianvs/prettier-plugin-sort-imports": "^4.3.1" - } + "name": "dojo.js", + "scripts": { + "build": "bash ./scripts/build-packages.sh", + "build-examples": "bash ./scripts/build-examples.sh", + "clean": "bash ./scripts/clean.sh", + "prettier-check": "npx prettier --check {packages,examples}", + "prettier": "npx prettier --write .", + "release": "pnpm build && pnpm prettier && npx lerna publish --no-private --force-publish", + "docs": "npx typedoc --out docs", + "prepare": "husky install" + }, + "devDependencies": { + "husky": "^9.1.6", + "lerna": "^8.1.5", + "prettier": "^3.3.3", + "tsup": "^8.1.0", + "typedoc": "^0.26.7", + "@typhonjs-typedoc/typedoc-theme-dmt": "^0.2.1", + "typedoc-plugin-coverage": "^3.3.0", + "@commitlint/cli": "^18.4.4", + "@commitlint/config-conventional": "^18.4.4", + "@ianvs/prettier-plugin-sort-imports": "^4.3.1" + } } diff --git a/packages/sdk/src/getEntities.ts b/packages/sdk/src/getEntities.ts index 34a21ff7..16530f96 100644 --- a/packages/sdk/src/getEntities.ts +++ b/packages/sdk/src/getEntities.ts @@ -34,6 +34,8 @@ export async function getEntities( data?: StandardizedQueryResult; error?: Error; }) => void, + orderBy: torii.OrderBy[] = [], + entityModels: string[] = [], limit: number = 100, // Default limit offset: number = 0, // Default offset options?: { logging?: boolean } // Logging option @@ -46,8 +48,10 @@ export async function getEntities( while (continueFetching) { const toriiQuery: torii.Query = { - limit: limit, + limit, offset: cursor, + order_by: orderBy, + entity_models: entityModels, clause, dont_include_hashed_keys: false, }; diff --git a/packages/sdk/src/getEventMessages.ts b/packages/sdk/src/getEventMessages.ts index c6e1ab7b..43cea296 100644 --- a/packages/sdk/src/getEventMessages.ts +++ b/packages/sdk/src/getEventMessages.ts @@ -34,6 +34,8 @@ export async function getEventMessages( data?: StandardizedQueryResult; error?: Error; }) => void, + orderBy: torii.OrderBy[] = [], + entityModels: string[] = [], limit: number = 100, // Default limit offset: number = 0, // Default offset options?: { logging?: boolean } // Logging option @@ -46,8 +48,10 @@ export async function getEventMessages( while (continueFetching) { const toriiQuery: torii.Query = { - limit: limit, + limit, offset: cursor, + order_by: orderBy, + entity_models: entityModels, clause, dont_include_hashed_keys: false, }; diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 92d51f41..a41e6a0d 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -61,12 +61,22 @@ export async function init( * @param {GetParams} params - Parameters object * @returns {Promise>} - A promise that resolves to the standardized query result. */ - getEntities: ({ query, callback, limit, offset, options }) => + getEntities: ({ + query, + callback, + orderBy, + entityModels, + limit, + offset, + options, + }) => getEntities( client, query, schema, callback, + orderBy, + entityModels, limit, offset, options @@ -77,12 +87,22 @@ export async function init( * @param {GetParams} params - Parameters object * @returns {Promise>} - A promise that resolves to the standardized query result. */ - getEventMessages: ({ query, callback, limit, offset, options }) => + getEventMessages: ({ + query, + callback, + orderBy, + entityModels, + limit, + offset, + options, + }) => getEventMessages( client, query, schema, callback, + orderBy, + entityModels, limit, offset, options diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 66fd5bc7..3ddda2b7 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -366,6 +366,10 @@ export interface GetParams { data?: StandardizedQueryResult; error?: Error; }) => void; + // The order to sort the entities by. + orderBy?: torii.OrderBy[]; + // The models to whitelist for fetching. Leave this empty to fetch all models. + entityModels?: string[]; // The maximum number of entities to fetch per request. Default is 100. limit?: number; // The offset to start fetching entities from. Default is 0. diff --git a/worlds/dojo-starter b/worlds/dojo-starter index d28df671..94de5ac8 160000 --- a/worlds/dojo-starter +++ b/worlds/dojo-starter @@ -1 +1 @@ -Subproject commit d28df671590a0ac59fc39a3df997fa3058c7b3c6 +Subproject commit 94de5ac8c3ae0c93e2b60291870b5591012ea729