Skip to content

Commit 1ac2903

Browse files
fix: build errors
1 parent 917d3a9 commit 1ac2903

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+279
-1625
lines changed

examples/react/react-app/src/dojo/generated/generated.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,28 @@ import { Account, AccountInterface } from "starknet";
22
import { DojoProvider } from "@dojoengine/core";
33
import { Direction } from "../../utils";
44

5-
export type IWorld = Awaited<ReturnType<typeof setupWorld>>;
5+
const NAMESPACE = "dojo_starter";
6+
7+
export interface IWorld {
8+
actions: {
9+
spawn: (props: { account: AccountInterface }) => Promise<any>;
10+
move: (props: MoveProps) => Promise<any>;
11+
};
12+
}
613

714
export interface MoveProps {
815
account: Account | AccountInterface;
916
direction: Direction;
1017
}
1118

12-
export async function setupWorld(provider: DojoProvider) {
13-
const nameSpace = "dojo_starter";
14-
function actions() {
15-
const spawn = async ({ account }: { account: AccountInterface }) => {
19+
const handleError = (action: string, error: unknown) => {
20+
console.error(`Error executing ${action}:`, error);
21+
throw error;
22+
};
23+
24+
export const setupWorld = async (provider: DojoProvider): Promise<IWorld> => {
25+
const actions = () => ({
26+
spawn: async ({ account }: { account: AccountInterface }) => {
1627
try {
1728
return await provider.execute(
1829
account,
@@ -21,15 +32,14 @@ export async function setupWorld(provider: DojoProvider) {
2132
entrypoint: "spawn",
2233
calldata: [],
2334
},
24-
nameSpace
35+
NAMESPACE
2536
);
2637
} catch (error) {
27-
console.error("Error executing spawn:", error);
28-
throw error;
38+
handleError("spawn", error);
2939
}
30-
};
40+
},
3141

32-
const move = async ({ account, direction }: MoveProps) => {
42+
move: async ({ account, direction }: MoveProps) => {
3343
try {
3444
return await provider.execute(
3545
account,
@@ -38,16 +48,13 @@ export async function setupWorld(provider: DojoProvider) {
3848
entrypoint: "move",
3949
calldata: [direction],
4050
},
41-
nameSpace
51+
NAMESPACE
4252
);
4353
} catch (error) {
44-
console.error("Error executing move:", error);
45-
throw error;
54+
handleError("move", error);
4655
}
47-
};
48-
return { spawn, move };
49-
}
50-
return {
51-
actions: actions(),
52-
};
53-
}
56+
},
57+
});
58+
59+
return { actions: actions() };
60+
};

examples/react/react-phaser-example/src/dojo/generated/contractComponents.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,32 @@ export type ContractComponents = Awaited<
1212

1313
export function defineContractComponents(world: World) {
1414
return {
15+
DirectionsAvailable: (() => {
16+
return defineComponent(
17+
world,
18+
{ player: RecsType.BigInt, directions: RecsType.StringArray },
19+
{
20+
metadata: {
21+
name: "dojo_starter-DirectionsAvailable",
22+
types: ["contractaddress"],
23+
customTypes: ["Direction"],
24+
},
25+
}
26+
);
27+
})(),
1528
Moves: (() => {
1629
return defineComponent(
1730
world,
1831
{
1932
player: RecsType.BigInt,
2033
remaining: RecsType.Number,
2134
last_direction: RecsType.Number,
35+
can_move: RecsType.Boolean,
2236
},
2337
{
2438
metadata: {
25-
name: "Moves",
26-
types: ["contractaddress", "u8", "enum"],
39+
name: "dojo_starter-Moves",
40+
types: ["contractaddress", "u8", "enum", "bool"],
2741
customTypes: ["Direction"],
2842
},
2943
}
@@ -38,7 +52,7 @@ export function defineContractComponents(world: World) {
3852
},
3953
{
4054
metadata: {
41-
name: "Position",
55+
name: "dojo_starter-Position",
4256
types: ["contractaddress", "u32", "u32"],
4357
customTypes: ["Vec2"],
4458
},

examples/react/react-phaser-example/src/dojo/generated/generated.ts

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,59 @@ import { Account, AccountInterface } from "starknet";
22
import { DojoProvider } from "@dojoengine/core";
33
import { Direction } from "../utils";
44

5-
export type IWorld = Awaited<ReturnType<typeof setupWorld>>;
5+
const NAMESPACE = "dojo_starter";
6+
7+
export interface IWorld {
8+
actions: {
9+
spawn: (props: { account: AccountInterface }) => Promise<any>;
10+
move: (props: MoveProps) => Promise<any>;
11+
};
12+
}
613

714
export interface MoveProps {
815
account: Account | AccountInterface;
916
direction: Direction;
1017
}
1118

12-
export async function setupWorld(provider: DojoProvider) {
13-
function actions() {
14-
const spawn = async ({ account }: { account: AccountInterface }) => {
19+
const handleError = (action: string, error: unknown) => {
20+
console.error(`Error executing ${action}:`, error);
21+
throw error;
22+
};
23+
24+
export const setupWorld = async (provider: DojoProvider): Promise<IWorld> => {
25+
const actions = () => ({
26+
spawn: async ({ account }: { account: AccountInterface }) => {
1527
try {
16-
return await provider.execute(account, {
17-
contractName: "actions",
18-
entrypoint: "spawn",
19-
calldata: [],
20-
});
28+
return await provider.execute(
29+
account,
30+
{
31+
contractName: "actions",
32+
entrypoint: "spawn",
33+
calldata: [],
34+
},
35+
NAMESPACE
36+
);
2137
} catch (error) {
22-
console.error("Error executing spawn:", error);
23-
throw error;
38+
handleError("spawn", error);
2439
}
25-
};
40+
},
2641

27-
const move = async ({ account, direction }: MoveProps) => {
42+
move: async ({ account, direction }: MoveProps) => {
2843
try {
29-
return await provider.execute(account, {
30-
contractName: "actions",
31-
entrypoint: "move",
32-
calldata: [direction],
33-
});
44+
return await provider.execute(
45+
account,
46+
{
47+
contractName: "actions",
48+
entrypoint: "move",
49+
calldata: [direction],
50+
},
51+
NAMESPACE
52+
);
3453
} catch (error) {
35-
console.error("Error executing move:", error);
36-
throw error;
54+
handleError("move", error);
3755
}
38-
};
39-
return { spawn, move };
40-
}
41-
return {
42-
actions: actions(),
43-
};
44-
}
56+
},
57+
});
58+
59+
return { actions: actions() };
60+
};

examples/react/react-phaser-example/src/dojo/generated/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function setup({ ...config }: DojoConfig) {
3333
const sync = await getSyncEntities(
3434
toriiClient,
3535
contractComponents as any,
36-
undefined // syncs all entities
36+
[]
3737
);
3838

3939
const client = await setupWorld(

examples/react/react-pwa-app/src/dojo/generated/contractComponents.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,32 @@ export type ContractComponents = Awaited<
1212

1313
export function defineContractComponents(world: World) {
1414
return {
15+
DirectionsAvailable: (() => {
16+
return defineComponent(
17+
world,
18+
{ player: RecsType.BigInt, directions: RecsType.StringArray },
19+
{
20+
metadata: {
21+
name: "dojo_starter-DirectionsAvailable",
22+
types: ["contractaddress"],
23+
customTypes: ["Direction"],
24+
},
25+
}
26+
);
27+
})(),
1528
Moves: (() => {
1629
return defineComponent(
1730
world,
1831
{
1932
player: RecsType.BigInt,
2033
remaining: RecsType.Number,
2134
last_direction: RecsType.Number,
35+
can_move: RecsType.Boolean,
2236
},
2337
{
2438
metadata: {
25-
name: "Moves",
26-
types: ["contractaddress", "u8", "enum"],
39+
name: "dojo_starter-Moves",
40+
types: ["contractaddress", "u8", "enum", "bool"],
2741
customTypes: ["Direction"],
2842
},
2943
}
@@ -38,7 +52,7 @@ export function defineContractComponents(world: World) {
3852
},
3953
{
4054
metadata: {
41-
name: "Position",
55+
name: "dojo_starter-Position",
4256
types: ["contractaddress", "u32", "u32"],
4357
customTypes: ["Vec2"],
4458
},

examples/react/react-pwa-app/src/dojo/generated/generated.ts

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,59 @@ import { Account, AccountInterface } from "starknet";
22
import { DojoProvider } from "@dojoengine/core";
33
import { Direction } from "../../utils";
44

5-
export type IWorld = Awaited<ReturnType<typeof setupWorld>>;
5+
const NAMESPACE = "dojo_starter";
6+
7+
export interface IWorld {
8+
actions: {
9+
spawn: (props: { account: AccountInterface }) => Promise<any>;
10+
move: (props: MoveProps) => Promise<any>;
11+
};
12+
}
613

714
export interface MoveProps {
815
account: Account | AccountInterface;
916
direction: Direction;
1017
}
1118

12-
export async function setupWorld(provider: DojoProvider) {
13-
function actions() {
14-
const spawn = async ({ account }: { account: AccountInterface }) => {
19+
const handleError = (action: string, error: unknown) => {
20+
console.error(`Error executing ${action}:`, error);
21+
throw error;
22+
};
23+
24+
export const setupWorld = async (provider: DojoProvider): Promise<IWorld> => {
25+
const actions = () => ({
26+
spawn: async ({ account }: { account: AccountInterface }) => {
1527
try {
16-
return await provider.execute(account, {
17-
contractName: "actions",
18-
entrypoint: "spawn",
19-
calldata: [],
20-
});
28+
return await provider.execute(
29+
account,
30+
{
31+
contractName: "actions",
32+
entrypoint: "spawn",
33+
calldata: [],
34+
},
35+
NAMESPACE
36+
);
2137
} catch (error) {
22-
console.error("Error executing spawn:", error);
23-
throw error;
38+
handleError("spawn", error);
2439
}
25-
};
40+
},
2641

27-
const move = async ({ account, direction }: MoveProps) => {
42+
move: async ({ account, direction }: MoveProps) => {
2843
try {
29-
return await provider.execute(account, {
30-
contractName: "actions",
31-
entrypoint: "move",
32-
calldata: [direction],
33-
});
44+
return await provider.execute(
45+
account,
46+
{
47+
contractName: "actions",
48+
entrypoint: "move",
49+
calldata: [direction],
50+
},
51+
NAMESPACE
52+
);
3453
} catch (error) {
35-
console.error("Error executing move:", error);
36-
throw error;
54+
handleError("move", error);
3755
}
38-
};
39-
return { spawn, move };
40-
}
41-
return {
42-
actions: actions(),
43-
};
44-
}
56+
},
57+
});
58+
59+
return { actions: actions() };
60+
};

examples/react/react-pwa-app/src/dojo/generated/setup.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ export async function setup({ ...config }: DojoConfig) {
3030
// create client components
3131
const clientComponents = createClientComponents({ contractComponents });
3232

33-
// fetch all existing entities from torii
3433
// fetch all existing entities from torii
3534
const sync = await getSyncEntities(
3635
toriiClient,
3736
contractComponents as any,
38-
undefined // syncs all entities
37+
[]
3938
);
4039

4140
// create dojo provider

0 commit comments

Comments
 (0)