Skip to content

Commit a10ad41

Browse files
fix: sync
1 parent 60d08ef commit a10ad41

File tree

12 files changed

+40
-32
lines changed

12 files changed

+40
-32
lines changed

examples/clients/react/react-app/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function App() {
1717
account,
1818
} = useDojo();
1919

20+
// sync entities
2021
useQuerySync(toriiClient, contractComponents as any, []);
2122

2223
const [clipboardStatus, setClipboardStatus] = useState({

examples/clients/react/react-app/src/dojo/setup.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { world } from "./world";
77
import { setupWorld } from "./typescript/contracts.gen";
88
import { Account, ArraySignatureType } from "starknet";
99
import { BurnerManager } from "@dojoengine/create-burner";
10-
import { getSyncEvents } from "@dojoengine/state";
10+
import { getSyncEvents, getSyncEntities } from "@dojoengine/state";
1111

1212
export type SetupResult = Awaited<ReturnType<typeof setup>>;
1313

@@ -29,13 +29,21 @@ export async function setup({ ...config }: DojoConfig) {
2929
// create dojo provider
3030
const dojoProvider = new DojoProvider(config.manifest, config.rpcUrl);
3131

32+
// Sync all events
3233
const eventSync = getSyncEvents(
3334
toriiClient,
3435
contractComponents as any,
3536
undefined,
3637
[]
3738
);
3839

40+
// Sync all entities
41+
const sync = await getSyncEntities(
42+
toriiClient,
43+
contractComponents as any,
44+
[]
45+
);
46+
3947
// setup world
4048
const client = await setupWorld(dojoProvider);
4149

@@ -75,5 +83,6 @@ export async function setup({ ...config }: DojoConfig) {
7583
burnerManager,
7684
toriiClient,
7785
eventSync,
86+
sync,
7887
};
7988
}

examples/dojo/dojo-starter/.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v3
1212
- run: curl -L https://install.dojoengine.org | bash
13-
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.0-alpha.6
13+
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.0-alpha.9
1414
- run: |
1515
/home/runner/.config/.dojo/bin/sozo build
1616
/home/runner/.config/.dojo/bin/sozo test

examples/dojo/dojo-starter/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ sozo build
4141
sozo migrate apply
4242

4343
# Start Torii
44-
torii --world 0x403b5f047b8c4797139e30801e310473d99ca6877d19e0f27506f353f8f70f7 --allowed-origins "*"
44+
torii --world 0x3b34889efbdf01f707d5d7421f112e8fb85a42fb6f2e5422c75ce3253148b0e --allowed-origins "*"
4545
```
4646

4747
---

examples/dojo/dojo-starter/Scarb.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = 1
44
[[package]]
55
name = "dojo"
66
version = "1.0.0-alpha.4"
7-
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.6#ede7930735c708572af8a87f81bb76354a401b3a"
7+
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.9#e42ce0c220a59d75c5b08e87a81de12cfdc27a55"
88
dependencies = [
99
"dojo_plugin",
1010
]

examples/dojo/dojo-starter/Scarb.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ spawn = "./scripts/spawn.sh"
1212
move = "./scripts/move.sh"
1313

1414
[dependencies]
15-
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.6" }
15+
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-alpha.9" }
1616

1717
[[target.dojo]]

examples/dojo/dojo-starter/dojo_dev.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ rpc_url = "http://localhost:5050/"
2020
# Default account for katana with seed = 0
2121
account_address = "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca"
2222
private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a"
23-
world_address = "0x403b5f047b8c4797139e30801e310473d99ca6877d19e0f27506f353f8f70f7"
23+
world_address = "0x3b34889efbdf01f707d5d7421f112e8fb85a42fb6f2e5422c75ce3253148b0e"

examples/dojo/dojo-starter/manifests/dev/base/contracts/dojo_starter-actions-7a1c7102.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
kind = "DojoContract"
2-
class_hash = "0x4f10da1ba615523c1a4b9e2ad40df134edbcf2d971a1074efbd9772c86c2173"
3-
original_class_hash = "0x4f10da1ba615523c1a4b9e2ad40df134edbcf2d971a1074efbd9772c86c2173"
2+
class_hash = "0x7304354bfea03508e0a8beaca98c9580c852a0e350b74dcafb55192c62fa3f4"
3+
original_class_hash = "0x7304354bfea03508e0a8beaca98c9580c852a0e350b74dcafb55192c62fa3f4"
44
base_class_hash = "0x0"
55
abi = "manifests/dev/base/abis/contracts/dojo_starter-actions-7a1c7102.json"
66
reads = []
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
kind = "Class"
2-
class_hash = "0x458d0ce5b14a4844092bdb62050f462d53362304a13febbac6d973691d61be2"
3-
original_class_hash = "0x458d0ce5b14a4844092bdb62050f462d53362304a13febbac6d973691d61be2"
2+
class_hash = "0xa349b743d361ce4567361475a89b84a386bb383448c6926954e5fe0b525597"
3+
original_class_hash = "0xa349b743d361ce4567361475a89b84a386bb383448c6926954e5fe0b525597"
44
abi = "manifests/dev/base/abis/dojo-world.json"
55
tag = "dojo-world"
66
manifest_name = "dojo-world"

examples/dojo/dojo-starter/manifests/dev/deployment/manifest.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"world": {
33
"kind": "WorldContract",
4-
"class_hash": "0x458d0ce5b14a4844092bdb62050f462d53362304a13febbac6d973691d61be2",
5-
"original_class_hash": "0x458d0ce5b14a4844092bdb62050f462d53362304a13febbac6d973691d61be2",
4+
"class_hash": "0xa349b743d361ce4567361475a89b84a386bb383448c6926954e5fe0b525597",
5+
"original_class_hash": "0xa349b743d361ce4567361475a89b84a386bb383448c6926954e5fe0b525597",
66
"abi": [
77
{
88
"type": "impl",
@@ -1229,8 +1229,8 @@
12291229
]
12301230
}
12311231
],
1232-
"address": "0x403b5f047b8c4797139e30801e310473d99ca6877d19e0f27506f353f8f70f7",
1233-
"transaction_hash": "0x12df6c5a6c89d2c128c96026395f1f8917c36a7864aca26f0c7b9e2ea152bca",
1232+
"address": "0x3b34889efbdf01f707d5d7421f112e8fb85a42fb6f2e5422c75ce3253148b0e",
1233+
"transaction_hash": "0x4729b83525f0dddbfce0afd73e0b6a39303de51690efd756691356c21c30067",
12341234
"block_number": 3,
12351235
"seed": "dojo_starter",
12361236
"metadata": {
@@ -1250,9 +1250,9 @@
12501250
"contracts": [
12511251
{
12521252
"kind": "DojoContract",
1253-
"address": "0x36e4506b35e6dfb301d437c95f74b3e1f4f82da5d8841bec894bb8de29ec13",
1254-
"class_hash": "0x4f10da1ba615523c1a4b9e2ad40df134edbcf2d971a1074efbd9772c86c2173",
1255-
"original_class_hash": "0x4f10da1ba615523c1a4b9e2ad40df134edbcf2d971a1074efbd9772c86c2173",
1253+
"address": "0x5e8df8a235031ba8e66e590a7289d27d7d54c026bcdbda62b791c0a69055225",
1254+
"class_hash": "0x7304354bfea03508e0a8beaca98c9580c852a0e350b74dcafb55192c62fa3f4",
1255+
"original_class_hash": "0x7304354bfea03508e0a8beaca98c9580c852a0e350b74dcafb55192c62fa3f4",
12561256
"base_class_hash": "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2",
12571257
"abi": [
12581258
{

examples/dojo/dojo-starter/manifests/dev/deployment/manifest.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[world]
22
kind = "WorldContract"
3-
class_hash = "0x458d0ce5b14a4844092bdb62050f462d53362304a13febbac6d973691d61be2"
4-
original_class_hash = "0x458d0ce5b14a4844092bdb62050f462d53362304a13febbac6d973691d61be2"
3+
class_hash = "0xa349b743d361ce4567361475a89b84a386bb383448c6926954e5fe0b525597"
4+
original_class_hash = "0xa349b743d361ce4567361475a89b84a386bb383448c6926954e5fe0b525597"
55
abi = "manifests/dev/deployment/abis/dojo-world.json"
6-
address = "0x403b5f047b8c4797139e30801e310473d99ca6877d19e0f27506f353f8f70f7"
7-
transaction_hash = "0x12df6c5a6c89d2c128c96026395f1f8917c36a7864aca26f0c7b9e2ea152bca"
6+
address = "0x3b34889efbdf01f707d5d7421f112e8fb85a42fb6f2e5422c75ce3253148b0e"
7+
transaction_hash = "0x4729b83525f0dddbfce0afd73e0b6a39303de51690efd756691356c21c30067"
88
block_number = 3
99
seed = "dojo_starter"
1010
manifest_name = "dojo-world"
@@ -23,9 +23,9 @@ manifest_name = "dojo-base"
2323

2424
[[contracts]]
2525
kind = "DojoContract"
26-
address = "0x36e4506b35e6dfb301d437c95f74b3e1f4f82da5d8841bec894bb8de29ec13"
27-
class_hash = "0x4f10da1ba615523c1a4b9e2ad40df134edbcf2d971a1074efbd9772c86c2173"
28-
original_class_hash = "0x4f10da1ba615523c1a4b9e2ad40df134edbcf2d971a1074efbd9772c86c2173"
26+
address = "0x5e8df8a235031ba8e66e590a7289d27d7d54c026bcdbda62b791c0a69055225"
27+
class_hash = "0x7304354bfea03508e0a8beaca98c9580c852a0e350b74dcafb55192c62fa3f4"
28+
original_class_hash = "0x7304354bfea03508e0a8beaca98c9580c852a0e350b74dcafb55192c62fa3f4"
2929
base_class_hash = "0x2427dd10a58850ac9a5ca6ce04b7771b05330fd18f2e481831ad903b969e6b2"
3030
abi = "manifests/dev/deployment/abis/contracts/dojo_starter-actions-7a1c7102.json"
3131
reads = []

packages/state/src/recs/index.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ export const getEntitiesQuery = async <S extends Schema>(
217217
}
218218
: null;
219219

220-
const fetchedEntities = await client.getEntities({
221-
limit,
222-
offset: cursor,
223-
clause: clause || undefined,
224-
});
225-
226220
while (continueFetching) {
221+
const fetchedEntities = await client.getEntities({
222+
limit,
223+
offset: cursor,
224+
clause: clause || undefined,
225+
});
226+
227227
setEntities(fetchedEntities, components);
228228

229229
if (Object.keys(fetchedEntities).length < limit) {
@@ -279,8 +279,6 @@ export const syncEvents = async <S extends Schema>(
279279
return await client.onEventMessageUpdated(
280280
entityKeyClause,
281281
(fetchedEntities: any, data: any) => {
282-
// Log the fetched entities and data for debugging purposes
283-
console.log("fetchedEntities", data);
284282
// Update the local state with the fetched entities and their data
285283
setEntities({ [fetchedEntities]: data }, components);
286284
}

0 commit comments

Comments
 (0)