-
Notifications
You must be signed in to change notification settings - Fork 0
/
walletview.SignMessageView.mjs
75 lines (69 loc) · 1.85 KB
/
walletview.SignMessageView.mjs
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
import { html } from "./htm.mjs";
import { useState } from "./thirdparty/hooks.mjs";
import { BitcoinWallet } from "./wallet.mjs";
/**
* @param {{
* wallet: BitcoinWallet,
* onClose: () => void,
* }} props
*/
export function SignMessageView({ wallet, onClose }) {
const [msg, setMsg] = useState("");
const [address, setAddress] = useState(wallet.getAddresses()[0]);
const signature = wallet.signMessage(msg, address);
return html`
<div class="send_view">
<div
class="tx_confirm_row"
style="justify-content: center; margin-bottom: 5px; margin-top: 20px;"
>
Enter message to sign:
</div>
<textarea
style="width: 100%; resize: none; margin-bottom: 10px"
placeholder=""
title=""
rows="10"
value=${msg}
onInput=${(/** @type {any} */ e) => {
setMsg(e.target.value);
}}
/>
<div
class="tx_confirm_row"
style="justify-content: center; margin-bottom: 5px; margin-top: 0px;"
>
Choose wallet address:
</div>
<select
value=${address}
onInput=${(/** @type {any} */ e) => {
setAddress(e.target.value);
}}
>
${wallet
.getAddresses()
.map(
(addr) => html`<option key=${addr} value=${addr}>${addr}</option>`
)}
</select>
<div
class="tx_confirm_row"
style="justify-content: center; margin-bottom: 5px; margin-top: 20px;"
>
Signature:
</div>
<textarea
style="width: 100%; resize: none; margin-bottom: 10px"
placeholder=""
title=""
rows="8"
readonly="true"
value=${signature}
/>
<div class="flex_column_center">
<button onClick=${onClose} style="width: 150px">Back</button>
</div>
</div>
`;
}