Skip to content

Commit 89eeedd

Browse files
authored
chore: update playground & tokens (#103)
1 parent e4dc4be commit 89eeedd

File tree

3 files changed

+116
-62
lines changed

3 files changed

+116
-62
lines changed

playground/entities.html

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
<html>
2-
3-
<head>
2+
<head>
43
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
5-
<link rel="stylesheet"
6-
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
4+
<link
5+
rel="stylesheet"
6+
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css"
7+
/>
78
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
8-
</head>
9+
</head>
910

10-
<body>
11+
<body>
1112
<script type="module">
12-
import init, { createClient, ClientConfig } from '../pkg/dojo_c.js';
13-
import { ThemeManager, UpdateManager } from './setup.js';
14-
15-
const themeManager = new ThemeManager();
16-
const updateManager = new UpdateManager();
13+
import init, { createClient, ClientConfig } from "../pkg/dojo_c.js";
14+
import { ThemeManager, UpdateManager } from "./setup.js";
1715

18-
async function run() {
19-
await init();
16+
const themeManager = new ThemeManager();
17+
const updateManager = new UpdateManager();
2018

21-
let config = {
22-
rpcUrl: 'http://localhost:5050',
23-
toriiUrl: 'http://localhost:8080',
24-
relayUrl: '',
25-
worldAddress: '0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be'
26-
}
19+
async function run() {
20+
await init();
2721

28-
let cconfig = new ClientConfig(config.rpcUrl, config.toriiUrl, config.relayUrl, config.worldAddress);
29-
const client = await createClient(cconfig);
22+
let config = {
23+
toriiUrl: "http://localhost:8080",
24+
relayUrl: "",
25+
worldAddress:
26+
"0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be",
27+
};
3028

31-
let entities = await client.getEntities({
32-
limit: 10,
33-
offset: 0,
34-
dont_include_hashed_keys: true,
35-
order_by: [],
36-
entity_models: [],
37-
entity_updated_after: 0,
38-
39-
});
29+
const client = await createClient(config);
4030

41-
updateManager.displayUpdate('fetch', entities);
31+
let entities = await client.getEntities({
32+
limit: 10,
33+
offset: 0,
34+
dont_include_hashed_keys: true,
35+
order_by: [],
36+
entity_models: [],
37+
entity_updated_after: 0,
38+
});
4239

43-
const subscription = await client.onEntityUpdated(
44-
[
45-
{
46-
Keys: {
47-
keys: [undefined],
48-
pattern_matching: "VariableLen",
49-
models: []
50-
}
51-
}
52-
], (entity_id, models) => {
53-
updateManager.displayUpdate('update', {
54-
entity_id: entity_id,
55-
models: models
56-
});
57-
});
40+
updateManager.displayUpdate("fetch", entities);
5841

59-
// Keeps the subscription alive.
60-
window.addEventListener('beforeunload', () => {
61-
if (subscription) {
62-
subscription.cancel();
63-
}
42+
const subscription = await client.onEntityUpdated(
43+
[
44+
{
45+
Keys: {
46+
keys: [undefined],
47+
pattern_matching: "VariableLen",
48+
models: [],
49+
},
50+
},
51+
],
52+
(entity_id, models) => {
53+
updateManager.displayUpdate("update", {
54+
entity_id: entity_id,
55+
models: models,
6456
});
65-
}
57+
}
58+
);
6659

67-
run().catch(error => {
68-
console.error(error);
69-
updateManager.displayUpdate('error', error.toString());
60+
// Keeps the subscription alive.
61+
window.addEventListener("beforeunload", () => {
62+
if (subscription) {
63+
subscription.cancel();
64+
}
7065
});
66+
}
7167

72-
console.log("a");
73-
</script>
74-
</body>
68+
run().catch((error) => {
69+
console.error(error);
70+
updateManager.displayUpdate("error", error.toString());
71+
});
7572

76-
</html>
73+
console.log("a");
74+
</script>
75+
</body>
76+
</html>

playground/events.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
await init();
2222

2323
let config = {
24-
rpcUrl: 'http://localhost:5050',
2524
toriiUrl: 'http://localhost:8080',
2625
relayUrl: '',
2726
worldAddress: '0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be'
2827
}
2928

30-
let cconfig = new ClientConfig(config.rpcUrl, config.toriiUrl, config.relayUrl, config.worldAddress);
31-
const client = await createClient(cconfig);
29+
const client = await createClient(config);
3230

3331
const is_historical = false;
3432

playground/tokens.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<html>
2+
3+
</html>
4+
5+
<head>
6+
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
7+
<link rel="stylesheet"
8+
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
9+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
10+
</head>
11+
12+
<body>
13+
<script type="module">
14+
import init, { createClient, ClientConfig } from '../pkg/dojo_c.js';
15+
import { ThemeManager, UpdateManager } from './setup.js';
16+
17+
const themeManager = new ThemeManager();
18+
const updateManager = new UpdateManager();
19+
20+
async function run() {
21+
await init();
22+
23+
let config = {
24+
toriiUrl: 'http://localhost:8080',
25+
relayUrl: '',
26+
worldAddress: '0x064613f376f05242dfcc9fe360fa2ce1fdd6b00b1ce73dae2ea649ea118fd9be'
27+
}
28+
29+
const client = await createClient(config);
30+
31+
let tokens = await client.getTokens([], []);
32+
33+
updateManager.displayUpdate("fetch", tokens);
34+
35+
const subscription = await client.onTokenUpdated([], [], (token) => {
36+
updateManager.displayUpdate("update", token);
37+
});
38+
39+
// Keeps the subscription alive.
40+
window.addEventListener('beforeunload', () => {
41+
if (subscription) {
42+
subscription.cancel();
43+
}
44+
});
45+
}
46+
47+
run().catch(error => {
48+
console.error(error);
49+
updateManager.displayUpdate('error', error.toString());
50+
});
51+
52+
console.log("a");
53+
</script>
54+
</body>
55+
56+
</html>

0 commit comments

Comments
 (0)