Skip to content

Commit ebcc425

Browse files
SunZhiCgitbook-bot
authored andcommitted
GITBOOK-1086: No subject
1 parent 0c84993 commit ebcc425

File tree

1 file changed

+28
-58
lines changed

1 file changed

+28
-58
lines changed

Diff for: developers/connect-service/sdks/flutter.md

+28-58
Original file line numberDiff line numberDiff line change
@@ -223,39 +223,45 @@ ParticleConnect.init(currChainInfo, dappInfo, Env.dev);
223223
224224
// set wallet connect support chaininfos, if you dont call this method
225225
// 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);
228231
```
229232
{% endhint %}
230233

231234
### Connect
232235

233236
```dart
234-
final result = await ParticleConnect.connect(WalletType.particle);
237+
final account = await ParticleConnect.connect(walletType);
235238
```
236239

237240
### Disconnect
238241

239242
```dart
240-
String result = await ParticleConnect.disconnect(WalletType.particle, getPublicAddress());
243+
String result = await ParticleConnect.disconnect(walletType, getPublicAddress());
241244
```
242245

243246
### IsConnected
244247

245248
```dart
246-
bool result = await ParticleConnect.isConnected(WalletType.particle, getPublicAddress());
249+
bool isConnected = await ParticleConnect.isConnected(walletType, getPublicAddress());
247250
```
248251

249-
### Login (Sign-In With Ethereum or Solana)
252+
### Sign-In With Ethereum or Solana
250253

251254
```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);
253258
```
254259

255260
### Verify
256261

257262
```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);
259265
```
260266

261267
### Sign message
@@ -264,7 +270,7 @@ In EVM chain requires a hexadecimal string, in Solana chain requires a human rea
264270

265271
```dart
266272
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);
268274
```
269275

270276
### Sign transaction
@@ -274,7 +280,7 @@ Only support Solana chain, in Solana chain requires a base58 string.
274280
Please explore our GitHub. In the `example/transaction_mock.dart` file, you can learn how to mock a test transaction.
275281

276282
```dart
277-
String result = await ParticleConnect.signTransaction(WalletType.particle, getPublicAddress(), transaction);
283+
String signature = await ParticleConnect.signTransaction(walletType, getPublicAddress(), transaction);
278284
```
279285

280286
### Sign all transactions
@@ -284,7 +290,7 @@ Only support Solana chain, in Solana chain requires a base58 string.
284290
Please explore our GitHub. In the `example/transaction_mock.dart` file, you can learn how to mock a test transaction.
285291

286292
```dart
287-
String result = await ParticleConnect.signAllTransactions(WalletType.particle, getPublicAddress(), transactions);
293+
String signature = await ParticleConnect.signAllTransactions(walletType, getPublicAddress(), transactions);
288294
```
289295

290296
### Sign and send transaction
@@ -294,7 +300,7 @@ In EVM chain requires a hexadecimal string, in Solana chain requires a base58 st
294300
Please explore our GitHub. In the `example/transaction_mock.dart` file, you can learn how to mock a test transaction.
295301

296302
```dart
297-
String result = await ParticleConnect.signAndSendTransaction(WalletType.particle, getPublicAddress(), transaction);
303+
String signature = await ParticleConnect.signAndSendTransaction(walletType, getPublicAddress(), transaction);
298304
```
299305

300306
### Sign typed data
@@ -303,72 +309,36 @@ In EVM chain requires a hexadecimal string, not support Solana.
303309

304310
```dart
305311
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);
308313
```
309314

310315
### Import private key
311316

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.
324318

325319
```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);
334321
```
335322

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
350324

351-
from test, this method works well in metamask, it doesn't work well in other wallets.
325+
Support both EVM and Solana mnemonics.
352326

353327
```dart
354-
int chainId = 80001;
355-
String result = await ParticleConnect.addEthereumChain(walletType, getPublicAddress(), chainId);
328+
final account = await ParticleConnect.importMnemonic(walletType, mnemonic);
356329
```
357330

358-
### Switch ethereum chain
331+
### Export private key
359332

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.
361334

362335
```dart
363-
int chainId = 5;
364-
String result = await ParticleConnect.switchEthereumChain(walletType, getPublicAddress(), chainId);
336+
String privateKey = await ParticleConnect.exportPrivateKey(walletType, getPublicAddress());
365337
```
366338

367339
### Reconnect wallet connect wallet
368340

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.
372342

373343
```dart
374344
ParticleConnect.reconnectIfNeeded(walletType, getPublicAddress());

0 commit comments

Comments
 (0)