-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (33 loc) · 1.12 KB
/
index.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
import './styles.css';
const inputMessage = document.getElementById("inputMessage");
const signButton = document.getElementById("signButton");
const outputMessage = document.getElementById('outputMessage');
signButton.addEventListener('click', handleClick);
const getWallet = () => {
const neolineN3 = new window.NEOLineN3.Init();
return neolineN3
};
async function handleClick() {
if (typeof window.NEOLineN3 !== "undefined") {
const wallet = getWallet();
const message = inputMessage.value;
if (message) {
wallet
.signMessage({
message
})
.then((response) => {
console.log("签名结果:", response);
outputMessage.textContent = `message\n${message}\n\nsignature:\n${response.data}\n\npublicKey:\n${response.publicKey}\n\nsalt:\n${response.salt}`;
})
.catch((error) => {
console.error("签名失败:", error);
alert("签名失败,请查看控制台以获取详细信息。");
});
} else {
alert("请输入要签名的字符串。");
}
} else {
alert("请安装Neoline插件。");
}
}