-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
41 lines (40 loc) · 1.49 KB
/
index.html
File metadata and controls
41 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html>
<head></head>
<body>
<h3>RACE Bundle Test</h3>
<div>Wallet Address:<span id="#wallet-addr"></span></div>
<button id="#connect">Connect Wallet</button>
<button id="#attach">Attach</button>
<div id="#state"></div>
<script src="./dist/main.js"></script>
<script>
// A function get called when a new player profile is fetched
const onProfile = (id, profile) => {
console.log('Profile #' + id, profile)
}
// A function get called when received an event
// The `event` can be empty, for the first time initialization
const onEvent = (state, event, player) => {
console.log('State:', state)
console.log('Event:', event)
console.log('Player:', player)
}
const onInfo = (info) => {
console.log('Info:', info)
}
document.getElementById("#connect").addEventListener("click", () => {
race.connectWallet().then(wallet => {
// `wallet` is the WalletAdapter from RACE.
document.getElementById("#wallet-addr").innerText = wallet.walletAddr
})
})
document.getElementById("#attach").addEventListener("click", () => {
// Attach to a game with its address. This is the HU table.
// Pass two callback functions to get notified when state changed.
const gameAddr = '2yYtuk5TcJWp1CH8rorSs4frcomd8mmNs87aFnYkc9K5'
race.attachGame(gameAddr, { onProfile, onEvent, onInfo })
})
</script>
</body>
</html>