Skip to content

Commit 4f43f92

Browse files
committed
Update for request method
1 parent 1d099ca commit 4f43f92

File tree

4 files changed

+140
-81
lines changed

4 files changed

+140
-81
lines changed

demo/rn-bare-example/App.tsx

Lines changed: 115 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ const resolvedRedirectUrl = `${scheme}://openlogin`;
2525
const 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+
2842
export 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()} />

demo/rn-bare-example/ethersRPC.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import '@ethersproject/shims';
2-
import {ethers} from 'ethers';
2+
import { ethers } from 'ethers';
33

4-
const providerUrl = 'https://rpc.ankr.com/eth'; // Or your desired provider url
4+
const providerUrl = 'https://rpc.ankr.com/eth_sepolia'; // Or your desired provider url
55

66
const getChainId = async () => {
77
try {

demo/rn-bare-example/package-lock.json

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/rnexpoexample/ios/Pods/Target Support Files/Pods-rnexpoexample/ExpoModulesProvider.swift

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)