From 4058649b149e799077e0f36724fc11d144b81562 Mon Sep 17 00:00:00 2001 From: Ben Kremer Date: Thu, 17 Feb 2022 11:33:12 +0100 Subject: [PATCH] feat: adds `web3Provider.send("eth_sign",...)` --- dapps/react-dapp-v2-with-ethers/src/App.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dapps/react-dapp-v2-with-ethers/src/App.tsx b/dapps/react-dapp-v2-with-ethers/src/App.tsx index 994b319..8f67f58 100644 --- a/dapps/react-dapp-v2-with-ethers/src/App.tsx +++ b/dapps/react-dapp-v2-with-ethers/src/App.tsx @@ -86,6 +86,23 @@ export default function App() { }; }; + const testEthSign: () => Promise = async () => { + if (!web3Provider) { + throw new Error("web3Provider not connected"); + } + const msg = "hello world"; + const hexMsg = encoding.utf8ToHex(msg, true); + const address = accounts[0]; + const signature = await web3Provider.send("eth_sign", [address, hexMsg]); + const valid = utils.verifyMessage(msg, signature) === address; + return { + method: "eth_sign (standard)", + address, + valid, + result: signature, + }; + }; + const testSignTypedData: () => Promise = async () => { if (!web3Provider) { throw new Error("web3Provider not connected"); @@ -160,6 +177,7 @@ export default function App() { return [ // { method: "eth_sendTransaction", callback: onSendTransaction }, { method: "personal_sign", callback: wrapRpcRequest(testSignMessage) }, + { method: "eth_sign (standard)", callback: wrapRpcRequest(testEthSign) }, { method: "eth_signTypedData", callback: wrapRpcRequest(testSignTypedData) }, ]; };