From 4ef529e2f8fe09a91a9cdf7dd86d8201e1fa9b48 Mon Sep 17 00:00:00 2001 From: Yashovardhan Agrawal <21066442+yashovardhan@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:42:30 +0530 Subject: [PATCH] bare app: Add request method function --- demo/rn-bare-example/App.tsx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/demo/rn-bare-example/App.tsx b/demo/rn-bare-example/App.tsx index f749ddb..c1e4a93 100644 --- a/demo/rn-bare-example/App.tsx +++ b/demo/rn-bare-example/App.tsx @@ -122,10 +122,10 @@ export default function App() { }; // IMP START - Blockchain Calls - const getAccounts = async () => { + const getAccounts = async (): Promise => { if (!provider) { uiConsole("provider not set"); - return; + return ""; } setConsole("Getting account"); // For ethers v5 @@ -139,6 +139,7 @@ export default function App() { // Get user's Ethereum public address const address = signer.getAddress(); uiConsole(address); + return address; }; const getBalance = async () => { @@ -204,6 +205,22 @@ export default function App() { setConsole(JSON.stringify(args || {}, null, 2) + "\n\n\n\n" + console); }; + const requestSignature = async () => { + if (!web3auth) { + setConsole("Web3auth not initialized"); + return; + } + try { + const address: string = await getAccounts(); + + const params = ["Hello World", address]; + const res = await web3auth.request(chainConfig, "personal_sign", params); + uiConsole(res); + } catch (error) { + uiConsole("Error in requestSignature:", error); + } + }; + const loggedInView = (