improved signing
This commit is contained in:
@@ -11,9 +11,10 @@ export const signMessage = async (provider: EIP1193Provider,userAccount: string)
|
||||
method: 'eth_getEncryptionPublicKey',
|
||||
params: [userAccount],
|
||||
})
|
||||
|
||||
const bytes = new TextEncoder().encode(String(publicKey));
|
||||
const msg = '0x' + Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
|
||||
// const bytes = new TextEncoder().encode(String(publicKey));
|
||||
// const msg = '0x' + Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
const msg = `0x${Buffer.from(String(publicKey), "utf8").toString("hex")}`
|
||||
const sign = await provider.request({
|
||||
method: "personal_sign",
|
||||
params: [msg, userAccount],
|
||||
|
||||
@@ -22,10 +22,9 @@ function NodeItem({node}: {node: Node}) {
|
||||
const connect = async ({ip}: {ip: string}) => {
|
||||
const res = await signMessage(auth.providerWithInfo.provider, auth.accounts[0]);
|
||||
try {
|
||||
let response = await axios.post('http://' + ip + ":8080/connect", res?.publicKey);
|
||||
const res_string = res?.publicKey + '\n' + res?.sign;
|
||||
let response = await axios.post('http://' + ip + ":8080/connect", res_string);
|
||||
console.log(response.data); // Log the response from the server
|
||||
// response = await axios.post('http://' + ip + ":8080/connect", res?.sign);
|
||||
// console.log(response.data); // Log the response from the server
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user