-
Notifications
You must be signed in to change notification settings - Fork 3
/
ui.js
72 lines (65 loc) · 1.49 KB
/
ui.js
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
import { panel, heading, text, copyable, divider } from '@metamask/snaps-ui';
export function renderGetPublicKey(host, pubkey) {
return snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Confirm access'),
text(host),
divider(),
text(pubkey)
])
}
});
}
export function renderSignTransaction(host, message) {
return snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Sign transaction'),
text(host),
divider(),
copyable(message)
])
}
});
}
export function renderSignAllTransactions(host, messages) {
if (messages.length === 1) {
return renderSignTransaction(host, messages[0]);
}
const uiElements = [];
for (let i = 0; i < messages.length; i++) {
uiElements.push(divider());
uiElements.push(text(`Transaction ${i + 1}`));
uiElements.push(copyable(messages[i]));
}
return snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Sign transactions'),
text(host),
...uiElements
])
}
});
}
export function renderSignMessage(host, message) {
return snap.request({
method: 'snap_dialog',
params: {
type: 'confirmation',
content: panel([
heading('Sign message'),
text(host),
divider(),
copyable(message)
])
}
});
}