Skip to content

Commit

Permalink
fix: coderabbitai feedback impl
Browse files Browse the repository at this point in the history
  • Loading branch information
okhaimie-dev committed Nov 28, 2024
1 parent 6a3f210 commit 4baf87a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/example-vite-react-sdk/dojoConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const dojoConfig = createDojoConfig({
toriiUrl: "http://localhost:8080",
masterAddress:
"0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec",
// WARNING: Do not use this private key in production!
// Use environment variables instead, e.g.: process.env.MASTER_PRIVATE_KEY
masterPrivateKey:
"0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912",
});
21 changes: 18 additions & 3 deletions examples/example-vite-react-sdk/src/useSystemCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,29 @@ export const useSystemCalls = () => {
await state.waitForEntityChange(
entityId,
(entity) => {
// Log the current state of the entity for debugging purposes
console.log("Entity state:", entity);

// Defensive checks to ensure the entity and its structure are valid
if (!entity) {
console.warn("Entity not found");
return false;
}
if (!entity.models?.dojo_starter?.Moves) {
console.warn(
"Entity does not have the expected model structure"
);
return false;
}

// Check if the remaining moves have been updated as expected
return (
entity?.models?.dojo_starter?.Moves?.remaining ===
entity.models.dojo_starter.Moves.remaining ===
remainingMoves
);
},
10000
); // Increased timeout to 10000ms
10000 // Increased timeout to 10000ms
);
} catch (error) {
state.revertOptimisticUpdate(transactionId);
console.error("Error executing spawn:", error);
Expand Down

0 comments on commit 4baf87a

Please sign in to comment.