-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: docs and example #231
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
## React-app | ||
## Dojo React Vite App | ||
|
||
[book](https://book.dojoengine.org/) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
## Phaser | ||
## Dojo Phaser React App | ||
|
||
### Instructions | ||
|
||
When running `components` script to generate a component file, make sure to replace already given **World address** with the World Address you get after running `sozo migrate`. | ||
[book](https://book.dojoengine.org/) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,14 @@ import { | |
import { Client } from "@dojoengine/torii-client"; | ||
import { convertValues } from "../utils"; | ||
|
||
/** | ||
* Fetches and synchronizes entities with their components. | ||
* @param client - The client instance for API communication. | ||
* @param components - An array of component definitions. | ||
* @param entities - An array of entities to synchronize. | ||
* @param limit - The maximum number of entities to fetch per request (default: 100). | ||
* @returns A promise that resolves when synchronization is complete. | ||
*/ | ||
export const getSyncEntities = async <S extends Schema>( | ||
client: Client, | ||
components: Component<S, Metadata, undefined>[], | ||
|
@@ -19,6 +27,12 @@ export const getSyncEntities = async <S extends Schema>( | |
return await syncEntities(client, components, entities); | ||
}; | ||
|
||
/** | ||
* Fetches all entities and their components from the client. | ||
* @param client - The client instance for API communication. | ||
* @param components - An array of component definitions. | ||
* @param limit - The maximum number of entities to fetch per request (default: 100). | ||
*/ | ||
Comment on lines
+33
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using Using entities: Entity[], |
||
export const getEntities = async <S extends Schema>( | ||
client: Client, | ||
components: Component<S, Metadata, undefined>[], | ||
|
@@ -40,6 +54,13 @@ export const getEntities = async <S extends Schema>( | |
} | ||
}; | ||
|
||
/** | ||
* Sets up a subscription to sync entity updates. | ||
* @param client - The client instance for API communication. | ||
* @param components - An array of component definitions. | ||
* @param entities - An array of entities to watch for updates. | ||
* @returns A promise that resolves with the subscription handler. | ||
*/ | ||
Comment on lines
+61
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using Using entities: Entity[], |
||
export const syncEntities = async <S extends Schema>( | ||
client: Client, | ||
components: Component<S, Metadata, undefined>[], | ||
|
@@ -50,6 +71,11 @@ export const syncEntities = async <S extends Schema>( | |
}); | ||
}; | ||
|
||
/** | ||
* Updates the components of entities in the local state. | ||
* @param entities - An array of entities with their updated component data. | ||
* @param components - An array of component definitions. | ||
*/ | ||
Comment on lines
+77
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using Using entities: Entity[], |
||
export const setEntities = async <S extends Schema>( | ||
entities: any[], | ||
components: Component<S, Metadata, undefined>[] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ Dojo.js is the official JavaScript SDK for interacting with Dojo worlds. It is c | |
|
||
Bootstrap a dojo world like so. You will need [dojo](https://github.com/dojoengine/dojo) installed. | ||
|
||
```console | ||
```bash | ||
npx @dojoengine/create-dojo | ||
``` | ||
|
||
|
@@ -34,7 +34,7 @@ npx @dojoengine/create-dojo | |
|
||
From the repository root, run the following to install all the necessary package dependencies: | ||
|
||
```console | ||
```bash | ||
pnpm i | ||
``` | ||
|
||
|
@@ -44,21 +44,21 @@ pnpm i | |
|
||
To build all packages, from the root directory, run: | ||
|
||
```console | ||
```bash | ||
pnpm run build | ||
``` | ||
|
||
To watch for changes on all packages in parallel, from the root directory, run: | ||
|
||
```console | ||
```bash | ||
pnpm run build-watch | ||
``` | ||
|
||
#### Dojo starter: | ||
|
||
To install dojo-starter submodule (which allows interactions with the examples), run: | ||
|
||
```console | ||
```bash | ||
git submodule update --init --recursive | ||
``` | ||
|
||
|
@@ -68,7 +68,7 @@ git submodule update --init --recursive | |
|
||
If you have issues on WSL, install package first then run command: | ||
|
||
```console | ||
```bash | ||
npm i @dojoengine/create-dojo -g | ||
npx @dojoengine/create-dojo | ||
``` | ||
|
@@ -79,22 +79,27 @@ To run the examples that have the linked packages, follow the steps below: | |
|
||
**Terminal 1**: Set up the dojo starter with specific configurations. | ||
|
||
```console | ||
```bash | ||
cd examples/dojo-starter | ||
katana --disable-fee --block-time 1000 | ||
katana --disable-fee --allowed-origins "*" | ||
Comment on lines
+82
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification Ensure the The
Analysis chainLGTM! But verify the usage of The command to set up the dojo starter with specific configurations looks good. However, ensure that users understand the purpose and implications of the Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the usage of `--allowed-origins` flag.
# Test: Search for the flag usage in the codebase. Expect: Documentation or comments explaining its purpose.
rg --type markdown --type js --type ts $'--allowed-origins'
Length of output: 478 Script: #!/bin/bash
# Description: Verify the usage of `--allowed-origins` flag.
# Test: Search for the flag usage in the codebase. Expect: Documentation or comments explaining its purpose.
rg --type markdown --type js --type ts '--allowed-origins'
Length of output: 478 Script: #!/bin/bash
# Description: Verify the usage of `--allowed-origins` flag.
# Test: Search for the flag usage in the codebase. Expect: Documentation or comments explaining its purpose.
rg --type markdown --type js --type ts '\-\-allowed-origins'
Length of output: 226 |
||
``` | ||
|
||
**Terminal 2**: Build and migrate the dojo starter. | ||
|
||
```console | ||
```bash | ||
cd examples/dojo-starter | ||
|
||
# Build and migrate | ||
sozo build | ||
sozo migrate | ||
sozo migrate apply | ||
|
||
# Run Torii | ||
torii --world 0xb4079627ebab1cd3cf9fd075dda1ad2454a7a448bf659591f259efa2519b18 --allowed-origins "*" | ||
``` | ||
|
||
**Terminal 3**: Start the React app. | ||
**Terminal 3**: Start the App | ||
|
||
```console | ||
```bash | ||
cd examples/<package> | ||
pnpm install | ||
pnpm run dev | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using
any
type forentities
.Using
any
type reduces type safety. Consider defining a specific type or interface forentities
.