Skip to content

Commit e283447

Browse files
fix: linting
1 parent 5bec93a commit e283447

File tree

9 files changed

+398
-59
lines changed

9 files changed

+398
-59
lines changed
-114 KB
Binary file not shown.

examples/example-vite-svelte-recs/dojoConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import manifest from "../manifests/dev/deployment/manifest.json";
1+
import manifest from "../../worlds/dojo-starter/manifests/dev/deployment/manifest.json";
22

33
import { createDojoConfig } from "@dojoengine/core";
44

examples/example-vite-svelte-recs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite + Svelte + TS</title>
7+
<title>Vite + Svelte + TS + Dojo</title>
88
</head>
99
<body>
1010
<div id="app"></div>

examples/example-vite-svelte-recs/src/App.svelte

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
<script lang="ts">
22
import type { Entity } from "@dojoengine/recs";
3-
import { componentValueStore, type ComponentStore } from "./dojo/componentValueStore";
3+
import {
4+
componentValueStore,
5+
type ComponentStore,
6+
} from "./dojo/componentValueStore";
47
import { dojoStore, accountStore, burnerStore } from "./stores";
58
import { Account } from "starknet";
69
import { type Burner } from "@dojoengine/create-burner";
7-
import { handleBurnerChange, handleNewBurner, handleClearBurners } from "./handlers";
10+
import {
11+
handleBurnerChange,
12+
handleNewBurner,
13+
handleClearBurners,
14+
} from "./handlers";
815
916
let entityId: Entity;
1017
let account: Account;
1118
let position: ComponentStore;
1219
let moves: ComponentStore;
13-
let burners: Burner[]
14-
15-
$: ({ clientComponents, torii, burnerManager, client } = $dojoStore);
16-
$: if ($accountStore) account = $accountStore;
20+
let burners: Burner[];
1721
18-
$: if (torii && account) entityId = torii.poseidonHash([account.address])
22+
$: ({ clientComponents, torii, burnerManager, client } = $dojoStore);
23+
$: if ($accountStore) account = $accountStore;
1924
20-
$: if (dojoStore) position = componentValueStore(clientComponents.Position, entityId);
21-
$: if (dojoStore) moves = componentValueStore(clientComponents.Moves, entityId);
22-
$: if ($burnerStore) burners = $burnerStore
25+
$: if (torii && account)
26+
entityId = torii.poseidonHash([account.address]) as Entity;
2327
28+
$: if (dojoStore)
29+
position = componentValueStore(clientComponents.Position, entityId);
30+
$: if (dojoStore)
31+
moves = componentValueStore(clientComponents.Moves, entityId);
32+
$: if ($burnerStore) burners = $burnerStore;
2433
</script>
2534

2635
<main>
@@ -40,21 +49,20 @@
4049
select signer:{" "}
4150
<select on:change={handleBurnerChange}>
4251
{#each burners as burner}
43-
<option value={burner.address}>
44-
{burner.address}
45-
</option>
52+
<option value={burner.address}>
53+
{burner.address}
54+
</option>
4655
{/each}
4756
</select>
4857
</div>
4958
<div>
50-
<button on:click={handleClearBurners}>
51-
Clear burners
52-
</button>
59+
<button on:click={handleClearBurners}> Clear burners </button>
5360
</div>
5461
</div>
5562

5663
<div class="card">
57-
<button on:click={() => client.actions.spawn({account})}>Spawn</button>
64+
<button on:click={() => client.actions.spawn({ account })}>Spawn</button
65+
>
5866
<div>
5967
Moves Left: {moves ? `${$moves?.remaining}` : "Need to Spawn"}
6068
</div>
@@ -66,17 +74,18 @@
6674
</div>
6775

6876
<div>{$moves && $moves.last_direction}</div>
69-
7077
</div>
7178

7279
<div class="card">
7380
<div>
7481
<button
7582
on:click={() =>
7683
position && $position.vec.y > 0
77-
? client.actions.move({account, direction:{ type: "Up" }})
78-
: console.log("Reach the borders of the world.")
79-
}
84+
? client.actions.move({
85+
account,
86+
direction: { type: "Up" },
87+
})
88+
: console.log("Reach the borders of the world.")}
8089
>
8190
Move Up
8291
</button>
@@ -85,21 +94,31 @@
8594
<button
8695
on:click={() =>
8796
position && $position.vec.x > 0
88-
? client.actions.move({account, direction: { type: "Left" }})
89-
: console.log("Reach the borders of the world.")
90-
}
97+
? client.actions.move({
98+
account,
99+
direction: { type: "Left" },
100+
})
101+
: console.log("Reach the borders of the world.")}
91102
>
92103
Move Left
93104
</button>
94105
<button
95-
on:click={() => client.actions.move({account, direction: { type: "Right" }})}
106+
on:click={() =>
107+
client.actions.move({
108+
account,
109+
direction: { type: "Right" },
110+
})}
96111
>
97112
Move Right
98113
</button>
99114
</div>
100115
<div>
101116
<button
102-
on:click={() => client.actions.move({account, direction: { type: "Down" }})}
117+
on:click={() =>
118+
client.actions.move({
119+
account,
120+
direction: { type: "Down" },
121+
})}
103122
>
104123
Move Down
105124
</button>

examples/example-vite-svelte-recs/src/handlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export function handleBurnerChange(event: Event) {
1111
accountStore.set(burnerManager.getActiveAccount());
1212
}
1313

14-
export async function handleNewBurner(event: Event) {
14+
export async function handleNewBurner() {
1515
burnerManager = get(dojoStore).burnerManager;
1616
await burnerManager.create();
1717
burnerStore.set(burnerManager.list());
1818
accountStore.set(burnerManager.getActiveAccount());
1919
}
2020

21-
export function handleClearBurners(event: Event) {
21+
export function handleClearBurners() {
2222
burnerManager = get(dojoStore).burnerManager;
2323
burnerManager.clear();
2424
burnerStore.set(burnerManager.list());

examples/example-vite-svelte-recs/src/main.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import { setup } from "./dojo/setup";
44
import { dojoConfig } from "../dojoConfig";
55
import { accountStore, burnerStore, dojoStore } from "./stores";
66

7-
// Create a writable store for the setup result
8-
97
async function initApp() {
10-
// Update the store with the setup result
8+
// Set up dojo
119
let setupRes = await setup(dojoConfig);
1210
dojoStore.set(setupRes);
1311
burnerStore.set(setupRes.burnerManager.list());

examples/example-vite-svelte-recs/src/stores.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { writable, derived } from "svelte/store";
1+
import { writable } from "svelte/store";
22
import { type SetupResult } from "./dojo/setup";
33
import { Account } from "starknet";
44
import { type Burner } from "@dojoengine/create-burner";

0 commit comments

Comments
 (0)