@@ -25,6 +25,20 @@ const resolvedRedirectUrl = `${scheme}://openlogin`;
2525const clientId =
2626 'BHr_dKcxC0ecKn_2dZQmQeNdjPgWykMkcodEHkVvPMo71qzOV6SgtoN8KCvFdLN7bf34JOm89vWQMLFmSfIo84A' ;
2727
28+ const chainConfig = {
29+ chainNamespace : ChainNamespace . EIP155 ,
30+ chainId : '0xaa36a7' ,
31+ rpcTarget : 'https://rpc.ankr.com/eth_sepolia' ,
32+ // Avoid using public rpcTarget in production.
33+ // Use services like Infura, Quicknode etc
34+ displayName : 'Ethereum Sepolia Testnet' ,
35+ blockExplorerUrl : 'https://sepolia.etherscan.io' ,
36+ ticker : 'ETH' ,
37+ tickerName : 'Ethereum' ,
38+ decimals : 18 ,
39+ logo : 'https://cryptologos.cc/logos/ethereum-eth-logo.png' ,
40+ } ;
41+
2842export default function App ( ) {
2943 const [ userInfo , setUserInfo ] = useState < OpenloginUserInfo | undefined > ( ) ;
3044 const [ key , setKey ] = useState < string | undefined > ( '' ) ;
@@ -92,14 +106,103 @@ export default function App() {
92106 }
93107
94108 setConsole ( 'Launch Wallet Services' ) ;
95- await web3auth . launchWalletServices ( {
96- chainNamespace : ChainNamespace . EIP155 ,
97- decimals : 18 ,
98- chainId : '0x1' ,
99- rpcTarget :
100- 'https://mainnet.infura.io/v3/daeee53504be4cd3a997d4f2718d33e0' ,
101- ticker : 'ETH' ,
102- } ) ;
109+ await web3auth . launchWalletServices ( chainConfig ) ;
110+ } ;
111+
112+ const requestSignature = async ( ) => {
113+ if ( ! web3auth ) {
114+ setConsole ( 'Web3auth not initialized' ) ;
115+ return ;
116+ }
117+ if ( ! key ) {
118+ setConsole ( 'User not logged in' ) ;
119+ return ;
120+ }
121+
122+ const address = await RPC . getAccounts ( key ) ;
123+
124+ // const params = [
125+ // {
126+ // challenge: 'Hello World',
127+ // address,
128+ // },
129+ // null,
130+ // ];
131+ // const params = ['Hello World', address];
132+ const params = [ ] ;
133+ params . push ( 'Hello World' ) ;
134+ params . push ( address ) ;
135+
136+ // const params = [
137+ // '0x0000000000000000000000000000000000000000',
138+ // {
139+ // types: {
140+ // EIP712Domain: [
141+ // {
142+ // name: 'name',
143+ // type: 'string',
144+ // },
145+ // {
146+ // name: 'version',
147+ // type: 'string',
148+ // },
149+ // {
150+ // name: 'chainId',
151+ // type: 'uint256',
152+ // },
153+ // {
154+ // name: 'verifyingContract',
155+ // type: 'address',
156+ // },
157+ // ],
158+ // Person: [
159+ // {
160+ // name: 'name',
161+ // type: 'string',
162+ // },
163+ // {
164+ // name: 'wallet',
165+ // type: 'address',
166+ // },
167+ // ],
168+ // Mail: [
169+ // {
170+ // name: 'from',
171+ // type: 'Person',
172+ // },
173+ // {
174+ // name: 'to',
175+ // type: 'Person',
176+ // },
177+ // {
178+ // name: 'contents',
179+ // type: 'string',
180+ // },
181+ // ],
182+ // },
183+ // primaryType: 'Mail',
184+ // domain: {
185+ // name: 'Ether Mail',
186+ // version: '1',
187+ // chainId: 1,
188+ // verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
189+ // },
190+ // message: {
191+ // from: {
192+ // name: 'Cow',
193+ // wallet: address,
194+ // },
195+ // to: {
196+ // name: 'Bob',
197+ // wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
198+ // },
199+ // contents: 'Hello, Bob!',
200+ // },
201+ // },
202+ // ];
203+
204+ setConsole ( 'Request Signature' ) ;
205+ await web3auth . request ( chainConfig , 'personal_sign' , params ) ;
103206 } ;
104207
105208 useEffect ( ( ) => {
@@ -178,6 +281,10 @@ export default function App() {
178281 title = "launch Wallet Services"
179282 onPress = { ( ) => launchWalletSerices ( ) }
180283 />
284+ < Button
285+ title = "Request Signature from Wallet Services"
286+ onPress = { ( ) => requestSignature ( ) }
287+ />
181288 < Button title = "Get Chain ID" onPress = { ( ) => getChainId ( ) } />
182289 < Button title = "Get Accounts" onPress = { ( ) => getAccounts ( ) } />
183290 < Button title = "Get Balance" onPress = { ( ) => getBalance ( ) } />
0 commit comments