Skip to content

Commit 4baf87a

Browse files
committed
fix: coderabbitai feedback impl
1 parent 6a3f210 commit 4baf87a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

examples/example-vite-react-sdk/dojoConfig.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const dojoConfig = createDojoConfig({
88
toriiUrl: "http://localhost:8080",
99
masterAddress:
1010
"0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec",
11+
// WARNING: Do not use this private key in production!
12+
// Use environment variables instead, e.g.: process.env.MASTER_PRIVATE_KEY
1113
masterPrivateKey:
1214
"0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912",
1315
});

examples/example-vite-react-sdk/src/useSystemCalls.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,29 @@ export const useSystemCalls = () => {
3535
await state.waitForEntityChange(
3636
entityId,
3737
(entity) => {
38+
// Log the current state of the entity for debugging purposes
3839
console.log("Entity state:", entity);
40+
41+
// Defensive checks to ensure the entity and its structure are valid
42+
if (!entity) {
43+
console.warn("Entity not found");
44+
return false;
45+
}
46+
if (!entity.models?.dojo_starter?.Moves) {
47+
console.warn(
48+
"Entity does not have the expected model structure"
49+
);
50+
return false;
51+
}
52+
53+
// Check if the remaining moves have been updated as expected
3954
return (
40-
entity?.models?.dojo_starter?.Moves?.remaining ===
55+
entity.models.dojo_starter.Moves.remaining ===
4156
remainingMoves
4257
);
4358
},
44-
10000
45-
); // Increased timeout to 10000ms
59+
10000 // Increased timeout to 10000ms
60+
);
4661
} catch (error) {
4762
state.revertOptimisticUpdate(transactionId);
4863
console.error("Error executing spawn:", error);

0 commit comments

Comments
 (0)