@@ -223,39 +223,45 @@ ParticleConnect.init(currChainInfo, dappInfo, Env.dev);
223
223
224
224
// set wallet connect support chaininfos, if you dont call this method
225
225
// default value is current chaininfo.
226
- List<ChainInfo> chainInfos = <ChainInfo>[EthereumChain.mainnet(), PolygonChain.mainnet()];
227
- ParticleConnect.setWalletConnectV2SupportChainInfos(chainInfos);
226
+ List<ChainInfo> chainInfos = <ChainInfo>[
227
+ ChainInfo.Ethereum,
228
+ ChainInfo.Polygon
229
+ ];
230
+ ParticleConnect.setWalletConnectV2SupportChainInfos(chainInfos);
228
231
```
229
232
{% endhint %}
230
233
231
234
### Connect
232
235
233
236
``` dart
234
- final result = await ParticleConnect.connect(WalletType.particle );
237
+ final account = await ParticleConnect.connect(walletType );
235
238
```
236
239
237
240
### Disconnect
238
241
239
242
``` dart
240
- String result = await ParticleConnect.disconnect(WalletType.particle , getPublicAddress());
243
+ String result = await ParticleConnect.disconnect(walletType , getPublicAddress());
241
244
```
242
245
243
246
### IsConnected
244
247
245
248
``` dart
246
- bool result = await ParticleConnect.isConnected(WalletType.particle , getPublicAddress());
249
+ bool isConnected = await ParticleConnect.isConnected(walletType , getPublicAddress());
247
250
```
248
251
249
- ### Login ( Sign-In With Ethereum or Solana)
252
+ ### Sign-In With Ethereum or Solana
250
253
251
254
``` dart
252
- String result = await ParticleConnect.login(WalletType.particle, getPublicAddress(), "login.xyz", "https://login.xyz/demo#login");
255
+ const domain = "particle.network";
256
+ const uri = "https://docs.particle.network/";
257
+ ConnectLogic.siwe = await ParticleConnect.signInWithEthereum(walletType, getPublicAddress(), domain, uri);
253
258
```
254
259
255
260
### Verify
256
261
257
262
``` dart
258
- String result = await ParticleConnect.verify(WalletType.particle, getPublicAddress(), message, signature);
263
+ bool result = await ParticleConnect.verify(walletType, getPublicAddress(),
264
+ ConnectLogic.siwe.message, ConnectLogic.siwe.signature);
259
265
```
260
266
261
267
### Sign message
@@ -264,7 +270,7 @@ In EVM chain requires a hexadecimal string, in Solana chain requires a human rea
264
270
265
271
``` dart
266
272
final messageHex = "0x${StringUtils.toHexString("Hello Particle")}";
267
- String result = await ParticleConnect.signMessage(WalletType.particle , getPublicAddress(), messageHex);
273
+ String signature = await ParticleConnect.signMessage(walletType , getPublicAddress(), messageHex);
268
274
```
269
275
270
276
### Sign transaction
@@ -274,7 +280,7 @@ Only support Solana chain, in Solana chain requires a base58 string.
274
280
Please explore our GitHub. In the ` example/transaction_mock.dart ` file, you can learn how to mock a test transaction.
275
281
276
282
``` dart
277
- String result = await ParticleConnect.signTransaction(WalletType.particle , getPublicAddress(), transaction);
283
+ String signature = await ParticleConnect.signTransaction(walletType , getPublicAddress(), transaction);
278
284
```
279
285
280
286
### Sign all transactions
@@ -284,7 +290,7 @@ Only support Solana chain, in Solana chain requires a base58 string.
284
290
Please explore our GitHub. In the ` example/transaction_mock.dart ` file, you can learn how to mock a test transaction.
285
291
286
292
``` dart
287
- String result = await ParticleConnect.signAllTransactions(WalletType.particle , getPublicAddress(), transactions);
293
+ String signature = await ParticleConnect.signAllTransactions(walletType , getPublicAddress(), transactions);
288
294
```
289
295
290
296
### Sign and send transaction
@@ -294,7 +300,7 @@ In EVM chain requires a hexadecimal string, in Solana chain requires a base58 st
294
300
Please explore our GitHub. In the ` example/transaction_mock.dart ` file, you can learn how to mock a test transaction.
295
301
296
302
``` dart
297
- String result = await ParticleConnect.signAndSendTransaction(WalletType.particle , getPublicAddress(), transaction);
303
+ String signature = await ParticleConnect.signAndSendTransaction(walletType , getPublicAddress(), transaction);
298
304
```
299
305
300
306
### Sign typed data
@@ -303,72 +309,36 @@ In EVM chain requires a hexadecimal string, not support Solana.
303
309
304
310
``` dart
305
311
String typedDataHex = "0x${StringUtils.toHexString(typedData)}";
306
- String result = await ParticleConnect.signTypedData(
307
- walletType, getPublicAddress(), typedDataHex);
312
+ String signature = await ParticleConnect.signTypedData(walletType, getPublicAddress(), typedDataHex);
308
313
```
309
314
310
315
### Import private key
311
316
312
- ``` dart
313
- String result = await ParticleConnect.importPrivateKey(WalletType.evmPrivateKey, privateKey);
314
- Map<String, dynamic> jsonResult = jsonDecode(result);
315
- if (jsonResult["status"] == 1 || jsonResult["status"] == true) {
316
- publicAddress = jsonResult["data"]["publicAddress"];
317
- print("publicAddress:$publicAddress");
318
- } else {
319
- print("${jsonResult["data"]}")
320
- }
321
- ```
322
-
323
- ### Import mnemonic
317
+ Support both EVM and Solana private keys.
324
318
325
319
``` dart
326
- String result = await ParticleConnect.importMnemonic(WalletType.evmPrivateKey, mnemonic);
327
- Map<String, dynamic> jsonResult = jsonDecode(result);
328
- if (jsonResult["status"] == 1 || jsonResult["status"] == true) {
329
- publicAddress = jsonResult["data"]["publicAddress"];
330
- print("publicAddress:$pubAddress");
331
- } else {
332
- print("${jsonResult["data"]}");
333
- }
320
+ final account = await ParticleConnect.importPrivateKey(walletType, privateKey);
334
321
```
335
322
336
- ### Export private key
337
-
338
- ``` dart
339
- String result = await ParticleConnect.exportPrivateKey(WalletType.evmPrivateKey, getPublicAddress());
340
- Map<String, dynamic> jsonResult = jsonDecode(result);
341
- if (jsonResult["status"] == 1 || jsonResult["status"] == true) {
342
- publicAddress = jsonResult["data"]["publicAddress"];
343
- print("pubAddress:$publicAddress");
344
- } else {
345
- print("${jsonResult["data"]}");
346
- }
347
- ```
348
-
349
- ### Add ethereum chain
323
+ ### Import mnemonic
350
324
351
- from test, this method works well in metamask, it doesn't work well in other wallets .
325
+ Support both EVM and Solana mnemonics .
352
326
353
327
``` dart
354
- int chainId = 80001;
355
- String result = await ParticleConnect.addEthereumChain(walletType, getPublicAddress(), chainId);
328
+ final account = await ParticleConnect.importMnemonic(walletType, mnemonic);
356
329
```
357
330
358
- ### Switch ethereum chain
331
+ ### Export private key
359
332
360
- from test, this method works well in metamask, it doesn't work well in other wallets .
333
+ Private keys can only be exported from accounts that have been imported through private keys or mnemonics .
361
334
362
335
``` dart
363
- int chainId = 5;
364
- String result = await ParticleConnect.switchEthereumChain(walletType, getPublicAddress(), chainId);
336
+ String privateKey = await ParticleConnect.exportPrivateKey(walletType, getPublicAddress());
365
337
```
366
338
367
339
### Reconnect wallet connect wallet
368
340
369
- only support iOS, usually use when open app, if current wallet is from wallet connect, call this method to reconnect, you can call this method anywhere anytime.
370
-
371
- It is better to start a connection before sign.
341
+ Only support iOS, works for extend wallet connect connection.
372
342
373
343
``` dart
374
344
ParticleConnect.reconnectIfNeeded(walletType, getPublicAddress());
0 commit comments