-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
83 lines (76 loc) · 3.82 KB
/
Copy pathindex.html
File metadata and controls
83 lines (76 loc) · 3.82 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SmartHoldem dApp Bridge — Test Page</title>
<style>
:root { color-scheme: dark; }
body { font-family: ui-monospace, monospace; background: #0e0f13; color: #e7e7ea; margin: 0; padding: 32px; }
h1 { font-size: 18px; letter-spacing: .08em; text-transform: uppercase; color: #f5a623; }
.card { max-width: 640px; border: 1px solid #2a2c34; border-radius: 12px; padding: 20px; }
button { background: #f5a623; color: #111; border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 700; cursor: pointer; margin: 4px 6px 4px 0; }
button:disabled { opacity: .4; cursor: not-allowed; }
pre { background: #15171d; border-radius: 8px; padding: 12px; overflow: auto; font-size: 12px; min-height: 60px; white-space: pre-wrap; }
.row { margin: 10px 0; }
input { width: 100%; background: #15171d; border: 1px solid #2a2c34; color: #e7e7ea; border-radius: 8px; padding: 8px; box-sizing: border-box; }
.ok { color: #2ecc71; } .err { color: #e74c3c; } .dim { color: #8a8d96; }
</style>
</head>
<body>
<div class="card">
<h1>SmartHoldem dApp Bridge — Test</h1>
<p class="dim" id="detect">Detecting provider…</p>
<div class="row">
<button id="account" disabled>getAccount()</button>
<button id="message" disabled>signMessage("hello")</button>
</div>
<div class="row">
<input id="recipient" placeholder="recipientId (S... STH address)" value="SSU6TvycebBMTvc8WHiKTfG9xmX1QSniZu" />
</div>
<div class="row">
<input id="amount" placeholder="amount (STH)" value="1" />
<input id="memo" placeholder="vendorField / memo" value="bridge-test" style="margin-top:6px" />
</div>
<div class="row">
<button id="send" disabled>sendTransaction()</button>
</div>
<pre id="out">—</pre>
</div>
<script>
const out = document.getElementById('out')
const log = (label, data, cls) => {
out.className = cls || ''
out.textContent = label + '\n' + (typeof data === 'string' ? data : JSON.stringify(data, null, 2))
}
const enable = (on) => ['account', 'message', 'send'].forEach((id) => (document.getElementById(id).disabled = !on))
function bind() {
const sth = window.smartholdem
document.getElementById('detect').innerHTML =
'<span class="ok">Provider found</span> · isSmartHoldem=' + sth.isSmartHoldem + ' · v' + sth.version + ' · ' + sth.network
enable(true)
document.getElementById('account').onclick = async () => {
try { log('getAccount →', await sth.getAccount(), 'ok') } catch (e) { log('getAccount ✗', e.message, 'err') }
}
document.getElementById('message').onclick = async () => {
try { log('signMessage →', await sth.signMessage('hello'), 'ok') } catch (e) { log('signMessage ✗', e.message, 'err') }
}
document.getElementById('send').onclick = async () => {
const payload = {
recipientId: document.getElementById('recipient').value.trim(),
amount: document.getElementById('amount').value.trim(),
vendorField: document.getElementById('memo').value.trim(),
}
log('sendTransaction → awaiting wallet approval…', payload, 'dim')
try { log('sendTransaction →', await sth.sendTransaction(payload), 'ok') }
catch (e) { log('sendTransaction ✗', e.message, 'err') }
}
}
if (window.smartholdem) bind()
else window.addEventListener('smartholdem#initialized', bind, { once: true })
// safety: poll briefly in case the init event fired before this script attached
let tries = 0
const t = setInterval(() => { if (window.smartholdem) { clearInterval(t); bind() } else if (++tries > 40) clearInterval(t) }, 100)
</script>
</body>
</html>