@@ -122,10 +122,10 @@ export default function App() {
122
122
} ;
123
123
124
124
// IMP START - Blockchain Calls
125
- const getAccounts = async ( ) => {
125
+ const getAccounts = async ( ) : Promise < string > => {
126
126
if ( ! provider ) {
127
127
uiConsole ( "provider not set" ) ;
128
- return ;
128
+ return "" ;
129
129
}
130
130
setConsole ( "Getting account" ) ;
131
131
// For ethers v5
@@ -139,6 +139,7 @@ export default function App() {
139
139
// Get user's Ethereum public address
140
140
const address = signer . getAddress ( ) ;
141
141
uiConsole ( address ) ;
142
+ return address ;
142
143
} ;
143
144
144
145
const getBalance = async ( ) => {
@@ -204,13 +205,30 @@ export default function App() {
204
205
setConsole ( JSON . stringify ( args || { } , null , 2 ) + "\n\n\n\n" + console ) ;
205
206
} ;
206
207
208
+ const requestSignature = async ( ) => {
209
+ if ( ! web3auth ) {
210
+ setConsole ( "Web3auth not initialized" ) ;
211
+ return ;
212
+ }
213
+ try {
214
+ const address : string = await getAccounts ( ) ;
215
+
216
+ const params = [ "Hello World" , address ] ;
217
+ const res = await web3auth . request ( chainConfig , "personal_sign" , params ) ;
218
+ uiConsole ( res ) ;
219
+ } catch ( error ) {
220
+ uiConsole ( "Error in requestSignature:" , error ) ;
221
+ }
222
+ } ;
223
+
207
224
const loggedInView = (
208
225
< View style = { styles . buttonArea } >
209
226
< Button title = "Get User Info" onPress = { ( ) => uiConsole ( web3auth . userInfo ( ) ) } />
210
227
< Button title = "Get Accounts" onPress = { ( ) => getAccounts ( ) } />
211
228
< Button title = "Get Balance" onPress = { ( ) => getBalance ( ) } />
212
229
< Button title = "Sign Message" onPress = { ( ) => signMessage ( ) } />
213
230
< Button title = "Show Wallet UI" onPress = { ( ) => launchWalletServices ( ) } />
231
+ < Button title = "Request Signature UI" onPress = { ( ) => requestSignature ( ) } />
214
232
< Button title = "Log Out" onPress = { logout } />
215
233
</ View >
216
234
) ;
0 commit comments