From 6d347cdec260ccb6c02ef5c05ee48f0f8b3f0a95 Mon Sep 17 00:00:00 2001 From: ponderingdemocritus Date: Mon, 21 Oct 2024 13:49:37 +1100 Subject: [PATCH 1/4] fix: constants --- packages/core/src/constants/index.ts | 6 +++--- worlds/dojo-starter | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/constants/index.ts b/packages/core/src/constants/index.ts index 295fb6d4..f816e14d 100644 --- a/packages/core/src/constants/index.ts +++ b/packages/core/src/constants/index.ts @@ -2,10 +2,10 @@ export const LOCAL_KATANA = "http://localhost:5050"; export const LOCAL_RELAY = ""; export const LOCAL_TORII = "http://0.0.0.0:8080"; export const KATANA_PREFUNDED_ADDRESS = - "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca"; + "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec"; export const KATANA_PREFUNDED_PRIVATE_KEY = - "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"; + "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec"; export const KATANA_CLASS_HASH = - "0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c"; + "0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2"; export const KATANA_ETH_CONTRACT_ADDRESS = "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"; diff --git a/worlds/dojo-starter b/worlds/dojo-starter index 42b56b04..8e84a8b6 160000 --- a/worlds/dojo-starter +++ b/worlds/dojo-starter @@ -1 +1 @@ -Subproject commit 42b56b04436d895d7e76e16bfe50d3f1796cbd27 +Subproject commit 8e84a8b62815bafcac48fcff299db2dd124efb2c From 3333a2cd900556945743133f7949c953ab02389b Mon Sep 17 00:00:00 2001 From: ponderingdemocritus Date: Mon, 21 Oct 2024 14:03:32 +1100 Subject: [PATCH 2/4] fix: dojo version --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e722bb40..1b1ef5e1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,7 +20,7 @@ jobs: run: git submodule update --init --recursive - run: curl -L https://install.dojoengine.org | bash - - run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.0-alpha.16 + - run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.0-alpha.17 - run: | cd worlds/dojo-starter /home/runner/.config/.dojo/bin/sozo build From 2dbe619d1f95e17223994c07b338eb0adc656441 Mon Sep 17 00:00:00 2001 From: ponderingdemocritus Date: Mon, 21 Oct 2024 14:38:26 +1100 Subject: [PATCH 3/4] fix: const type --- packages/core/src/constants/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/constants/index.ts b/packages/core/src/constants/index.ts index f816e14d..c1f89346 100644 --- a/packages/core/src/constants/index.ts +++ b/packages/core/src/constants/index.ts @@ -4,7 +4,7 @@ export const LOCAL_TORII = "http://0.0.0.0:8080"; export const KATANA_PREFUNDED_ADDRESS = "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec"; export const KATANA_PREFUNDED_PRIVATE_KEY = - "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec"; + "0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912"; export const KATANA_CLASS_HASH = "0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2"; export const KATANA_ETH_CONTRACT_ADDRESS = From 640ec757d9e1fdf4486c94f0c13802bce67015f4 Mon Sep 17 00:00:00 2001 From: ponderingdemocritus Date: Tue, 22 Oct 2024 06:53:43 +1100 Subject: [PATCH 4/4] fix: linting --- .../example-vite-react-app-recs/src/App.tsx | 2 ++ packages/state/src/recs/index.ts | 25 +++++++++++++++---- readme.md | 2 +- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/examples/example-vite-react-app-recs/src/App.tsx b/examples/example-vite-react-app-recs/src/App.tsx index 796a1b76..00ee191a 100644 --- a/examples/example-vite-react-app-recs/src/App.tsx +++ b/examples/example-vite-react-app-recs/src/App.tsx @@ -16,6 +16,8 @@ function App() { account, } = useDojo(); + // sync the contract components to the local state + // this fetches the entities from the world and updates the local state useQuerySync(toriiClient, contractComponents as any, []); const [clipboardStatus, setClipboardStatus] = useState({ diff --git a/packages/state/src/recs/index.ts b/packages/state/src/recs/index.ts index e3aa1660..7f82f7de 100644 --- a/packages/state/src/recs/index.ts +++ b/packages/state/src/recs/index.ts @@ -51,7 +51,7 @@ export const getSyncEntities = async ( limit: number = 100, logging: boolean = false ) => { - if (logging) console.log("Starting getSyncEntities"); + if (logging) console.log("Starting getSyncEntities ", clause); await getEntities(client, clause, components, limit, logging); return await syncEntities(client, components, entityKeyClause, logging); }; @@ -126,9 +126,11 @@ export const getEntities = async ( limit, offset, clause, - dont_include_hashed_keys: true, + dont_include_hashed_keys: false, }); + console.log("entities", entities); + if (logging) console.log(`Fetched ${entities} entities`); setEntities(entities, components, logging); @@ -165,7 +167,7 @@ export const getEvents = async ( limit, offset, clause, - dont_include_hashed_keys: true, + dont_include_hashed_keys: false, }); if (logging) console.log("entities", entities); @@ -232,14 +234,15 @@ export const getEntitiesQuery = async ( limit, offset: cursor, clause: clause || undefined, - dont_include_hashed_keys: true, + dont_include_hashed_keys: false, }); while (continueFetching) { if (logging) console.log( - `Fetched ${Object.keys(fetchedEntities).length} entities` + `Fetched ${Object.keys(fetchedEntities).length} entities ${cursor}` ); + setEntities(fetchedEntities, components, logging); if (Object.keys(fetchedEntities).length < limit) { @@ -273,6 +276,7 @@ export const syncEntities = async ( entityKeyClause, (fetchedEntities: any, data: any) => { if (logging) console.log("Entity updated", fetchedEntities); + setEntities({ [fetchedEntities]: data }, components, logging); } ); @@ -301,6 +305,7 @@ export const syncEvents = async ( entityKeyClause, (fetchedEntities: any, data: any) => { if (logging) console.log("Event message updated", fetchedEntities); + setEntities({ [fetchedEntities]: data }, components, logging); } ); @@ -317,6 +322,16 @@ export const setEntities = async ( components: Component[], logging: boolean = false ) => { + if ( + Object.keys(entities).length === 0 || + (Object.keys(entities).length === 1 && + entities["0x0"] && + Object.keys(entities["0x0"]).length === 0) + ) { + console.warn("No entities to set"); + return; + } + if (logging) console.log("Entities to set:", entities); for (let key in entities) { diff --git a/readme.md b/readme.md index b08d7b76..02a28cdb 100644 --- a/readme.md +++ b/readme.md @@ -46,7 +46,7 @@ npx @dojoengine/create-dojo start -t example-vite-react-sdk ```bash cd dojo-starter - sozo build && sozo migrate + sozo build && sozo migrate apply # Start Torii indexer - world address can be found in the print out of migrate torii --world --allowed-origins "*"