Ive had an issue when trying to sign messages where the from address here is invalid. The function getSelectedOrRequestAddress() returns a JSON stringified rpc response but the method call to eip6963WalletRequest(..) params and from parameters require the fromAddress to be a simple string.
|
const from = await this.getSelectedOrRequestAddress(); |
For now Ive manually implemented the following into my code which has resolved the issue but not sure if there is a cleaner/more appropriate way of doing this. I'm also not sure what happens if the getSelectedOrRequestAddress() returns multiple account results.
try { const from = await this.getSelectedOrRequestAddress(); log("Signing from: " + from); const parsedFrom = JSON.parse(from); const fromAddress = parsedFrom.result[0]; const params = [utf8HexMsg, fromAddress]; const method = 'personal_sign'; const rpcResponse = await this.eip6963WalletRequest({ method, params, fromAddress }); return JSON.stringify(rpcResponse); } catch (e) { log("Error signing: " + e); return JSON.stringify({ jsonrpc: "2.0", id: null, error: e }); }
Ive had an issue when trying to sign messages where the from address here is invalid. The function getSelectedOrRequestAddress() returns a JSON stringified rpc response but the method call to eip6963WalletRequest(..) params and from parameters require the fromAddress to be a simple string.
Nethereum/src/Nethereum.Blazor/wwwroot/NethereumEIP6963.js
Line 144 in 24adce3
For now Ive manually implemented the following into my code which has resolved the issue but not sure if there is a cleaner/more appropriate way of doing this. I'm also not sure what happens if the getSelectedOrRequestAddress() returns multiple account results.
try { const from = await this.getSelectedOrRequestAddress(); log("Signing from: " + from); const parsedFrom = JSON.parse(from); const fromAddress = parsedFrom.result[0]; const params = [utf8HexMsg, fromAddress]; const method = 'personal_sign'; const rpcResponse = await this.eip6963WalletRequest({ method, params, fromAddress }); return JSON.stringify(rpcResponse); } catch (e) { log("Error signing: " + e); return JSON.stringify({ jsonrpc: "2.0", id: null, error: e }); }