Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/example-vanillajs-phaser-recs/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export async function setup({ ...config }: Config) {
sync = await getSyncEntities(
toriiClient,
contractModels as any,
[],
1000
undefined,
[]
);
} catch (e) {
console.error("Failed to fetch sync:", e);
Expand Down
12 changes: 10 additions & 2 deletions examples/example-vite-react-app-recs/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,16 @@ export async function setup({ ...config }: DojoConfig) {
clientComponents,
contractComponents,
systemCalls: createSystemCalls({ client }, clientComponents, world),
publish: (typedData: string, signature: ArraySignatureType) => {
toriiClient.publishMessage(typedData, signature);
publish: (
typedData: string,
signature: ArraySignatureType,
isSessionSignature = false
) => {
toriiClient.publishMessage(
typedData,
signature,
isSessionSignature
);
},
config,
dojoProvider,
Expand Down
25 changes: 13 additions & 12 deletions examples/example-vite-react-phaser-recs/src/dojo/generated/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,8 @@ import { createSystemCalls } from "../createSystemCalls";
import { defineContractComponents } from "./contractComponents";
import { world } from "./world";
import { setupWorld } from "./generated";
import {
DojoConfig,
DojoProvider,
createModelTypedData,
} from "@dojoengine/core";
import {
ArraySignatureType,
TypedData,
WeierstrassSignatureType,
} from "starknet";
import { DojoConfig, DojoProvider } from "@dojoengine/core";
import { ArraySignatureType } from "starknet";

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

Expand All @@ -37,6 +29,7 @@ export async function setup({ ...config }: DojoConfig) {
const sync = await getSyncEntities(
toriiClient,
contractComponents as any,
undefined,
[]
);

Expand All @@ -53,8 +46,16 @@ export async function setup({ ...config }: DojoConfig) {
contractComponents,
clientComponents
),
publish: (typedData: string, signature: ArraySignatureType) => {
toriiClient.publishMessage(typedData, signature);
publish: (
typedData: string,
signature: ArraySignatureType,
isSessionSignature = false
) => {
toriiClient.publishMessage(
typedData,
signature,
isSessionSignature
);
},
config,
sync,
Expand Down
26 changes: 13 additions & 13 deletions examples/example-vite-react-pwa-recs/src/dojo/generated/setup.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import {
createModelTypedData,
DojoConfig,
DojoProvider,
} from "@dojoengine/core";
import { DojoConfig, DojoProvider } from "@dojoengine/core";
import { BurnerManager } from "@dojoengine/create-burner";
import { getSyncEntities } from "@dojoengine/state";
import * as torii from "@dojoengine/torii-client";
import {
Account,
ArraySignatureType,
TypedData,
WeierstrassSignatureType,
} from "starknet";
import { Account, ArraySignatureType } from "starknet";

import { createClientComponents } from "../createClientComponents";
import { createSystemCalls } from "../createSystemCalls";
Expand Down Expand Up @@ -40,6 +31,7 @@ export async function setup({ ...config }: DojoConfig) {
const sync = await getSyncEntities(
toriiClient,
contractComponents as any,
undefined,
[]
);

Expand Down Expand Up @@ -81,8 +73,16 @@ export async function setup({ ...config }: DojoConfig) {
contractComponents,
clientComponents
),
publish: (typedData: string, signature: ArraySignatureType) => {
toriiClient.publishMessage(typedData, signature);
publish: (
typedData: string,
signature: ArraySignatureType,
isSessionSignature = false
) => {
toriiClient.publishMessage(
typedData,
signature,
isSessionSignature
);
},
config,
dojoProvider,
Expand Down
85 changes: 35 additions & 50 deletions examples/example-vite-react-sdk/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useMemo } from "react";
import { SDK, createDojoStore } from "@dojoengine/sdk";
import { QueryBuilder, SDK, createDojoStore } from "@dojoengine/sdk";
import { getEntityIdFromKeys } from "@dojoengine/utils";
import { addAddressPadding } from "starknet";

Expand Down Expand Up @@ -38,34 +38,25 @@ function App({ sdk }: { sdk: SDK<Schema> }) {
let unsubscribe: (() => void) | undefined;

const subscribe = async () => {
const subscription = await sdk.subscribeEntityQuery(
{
dojo_starter: {
Moves: {
$: {
where: {
player: {
$is: addAddressPadding(
account.account.address
),
},
},
},
},
Position: {
$: {
where: {
player: {
$is: addAddressPadding(
account.account.address
),
},
},
},
},
},
},
(response) => {
const subscription = await sdk.subscribeEntityQuery({
query: new QueryBuilder<Schema>()
.namespace("dojo_starter", (n) =>
n
.entity("Moves", (e) =>
e.eq(
"player",
addAddressPadding(account.account.address)
)
)
.entity("Position", (e) =>
e.is(
"player",
addAddressPadding(account.account.address)
)
)
)
.build(),
callback: (response) => {
if (response.error) {
console.error(
"Error setting up entity sync:",
Expand All @@ -79,8 +70,7 @@ function App({ sdk }: { sdk: SDK<Schema> }) {
state.updateEntity(response.data[0]);
}
},
{ logging: true }
);
});

unsubscribe = () => subscription.cancel();
};
Expand All @@ -97,23 +87,18 @@ function App({ sdk }: { sdk: SDK<Schema> }) {
useEffect(() => {
const fetchEntities = async () => {
try {
await sdk.getEntities(
{
dojo_starter: {
Moves: {
$: {
where: {
player: {
$eq: addAddressPadding(
account.account.address
),
},
},
},
},
},
},
(resp) => {
await sdk.getEntities({
query: new QueryBuilder<Schema>()
.namespace("dojo_starter", (n) =>
n.entity("Moves", (e) =>
e.eq(
"player",
addAddressPadding(account.account.address)
)
)
)
.build(),
callback: (resp) => {
if (resp.error) {
console.error(
"resp.error.message:",
Expand All @@ -124,8 +109,8 @@ function App({ sdk }: { sdk: SDK<Schema> }) {
if (resp.data) {
state.setEntities(resp.data);
}
}
);
},
});
} catch (error) {
console.error("Error querying entities:", error);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/example-vite-react-sdk/src/contracts.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Import the necessary types from the recs SDK
// generate again with `sozo build --typescript`
import { DojoProvider } from "@dojoengine/core";
import { Account, byteArray } from "starknet";
import { Account } from "starknet";

export type IClient = Awaited<ReturnType<typeof client>>;

Expand Down
2 changes: 1 addition & 1 deletion examples/example-vite-react-sdk/tsconfig.app.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./src/app.tsx","./src/bindings.ts","./src/main.tsx","./src/vite-env.d.ts"],"version":"5.6.2"}
{"root":["./src/app.tsx","./src/dojocontext.tsx","./src/bindings.ts","./src/contracts.gen.ts","./src/main.tsx","./src/usedojo.tsx","./src/usemodel.tsx","./src/usesystemcalls.ts","./src/vite-env.d.ts"],"version":"5.6.3"}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Add .tsbuildinfo files to .gitignore to prevent committing build artifacts

The verification confirms:

  1. .tsbuildinfo files are currently not ignored in version control
  2. All referenced TypeScript files exist in the codebase (with slight case differences)

Add this line to your .gitignore:

*.tsbuildinfo
🔗 Analysis chain

Consider adding .tsbuildinfo files to .gitignore

The .tsbuildinfo files are TypeScript build cache files that should typically not be committed to version control. They are automatically generated during compilation and can cause unnecessary merge conflicts.

Let's verify if this file is already ignored and check the existence of the newly added TypeScript files:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify .gitignore settings and existence of TypeScript files

# Check if .tsbuildinfo is already ignored
echo "Checking .gitignore for .tsbuildinfo:"
rg "\.tsbuildinfo$" .gitignore || echo "Not ignored"

# Verify existence of the newly added TypeScript files
echo -e "\nVerifying existence of TypeScript files:"
for file in "dojocontext.tsx" "contracts.gen.ts" "usedojo.tsx" "usemodel.tsx" "usesystemcalls.ts"; do
    fd -p "examples/example-vite-react-sdk/src/${file}$" || echo "Missing: $file"
done

Length of output: 1314

2 changes: 1 addition & 1 deletion examples/example-vite-react-sdk/tsconfig.node.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./vite.config.ts"],"version":"5.6.2"}
{"root":["./vite.config.ts"],"version":"5.6.3"}
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import {
createModelTypedData,
DojoConfig,
DojoProvider,
} from "@dojoengine/core";
import { DojoConfig, DojoProvider } from "@dojoengine/core";
import { BurnerManager } from "@dojoengine/create-burner";
import { getSyncEntities } from "@dojoengine/state";
import * as torii from "@dojoengine/torii-client";
import {
Account,
ArraySignatureType,
RpcProvider,
Signature,
TypedData,
WeierstrassSignatureType,
} from "starknet";
import { Account, ArraySignatureType } from "starknet";

import { createClientComponents } from "../createClientComponents";
import { createSystemCalls } from "../createSystemCalls";
Expand Down Expand Up @@ -43,6 +32,7 @@ export async function setup({ ...config }: DojoConfig) {
const sync = await getSyncEntities(
toriiClient,
contractComponents as any,
undefined,
[]
);

Expand Down Expand Up @@ -83,8 +73,16 @@ export async function setup({ ...config }: DojoConfig) {
contractComponents,
clientComponents
),
publish: (typedData: string, signature: ArraySignatureType) => {
toriiClient.publishMessage(typedData, signature);
publish: (
typedData: string,
signature: ArraySignatureType,
isSessionSignature: boolean = false
) => {
toriiClient.publishMessage(
typedData,
signature,
isSessionSignature
);
},
config,
world,
Expand Down
3 changes: 2 additions & 1 deletion examples/example-vite-svelte-recs/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
dist/
Loading